How to use Unity Scripting with Vuforia - c#

This maybe a stupid question but this keeps moving in my mind.
here's the situation.
I have a small application deployed in Hololens and using vuforia extensions, I'm able to track and recognize a real 3d object. I'm able to make holograms appear too, as long as holograms are children of the target object.
What I want to do is to activate or deactivate holograms that is not a child of the target object. I can't do it through code since the script i'm manipulating is a name space.
I tried putting methods inside the namespace itself but i keep having exceptions and nothing works.
I hope you can help me with this one.
Ty

You can use Instantiate https://docs.unity3d.com/ScriptReference/Object.Instantiate.html
to create an object as soon as Vuforia has recognizes a specific target (Wich you can check by using one of the targetablemanagers.)

Related

Unity Prefab Not Updating On Old Android Tablet

I have a Samsung Galaxy Tab Active 1, on the latest version of android it can handle, and just recently, after adding accessibility features that shouldn’t affect anything, the balls in my game stopped updating. I instantiate a ball, and change a few properties on it, and then for some reason I think it’s not calling the update method. There are no errors.
I’ve heard using PrefabUtility to instantiate might help, but I haven’t done that just yet. I will update if PrefabUtility works.
Any advice?
Whoops, this was due to me being a bit stupid. The main reason it was happening was because of a parsing error in some of the accesibility settings, as they were not saved correctly due to weirdness I can't wrap my head around with files in Android. TLDR: file did not save correctly, and so did not load correctly, and so data messed up, and so it errored before it could do anything.

How to fix "Unity transform position changes after build to WebGL"?

This is my first time to make a Unity project. Everything works well on the Game view in Unity Editor. However, after I built the project and played it on Google Chrome, I found that the position of some gameobjects had been changed.
Here is a more detailed explanation. The left is what I saw on the game view, which was perfect. The right side is what I saw after built the project. The position of the grey picture had been changed.
Does anyone know how to fix this?
ps.I am using Unity 2020.3.18 with WebGL platform
Try exporting again but with the same resolution as the game view. In this case you would want to export in a 400x600 resolution (You can also edit the "index.html" file to change and experiment with the resolution). The problem has to do with the fact that changing the resolution of the game can affect where certain objects are and how much you can see.

DontDestroyOnLoad - how to destroy?

I'm working on a Vuforia (legacy) application.
In "Play" mode in Unity I can see that some "DontDestroyOnLoad" content is being generated, (looks like it's sort of a camera).
This might be a reason of why I have some problems when switching between the scenes, so the question is how to make these elements "destroyable"?
'DontDestroyOnLoad' It means that they won't manage it automatically. so if you want to destroy it, you should destroy manually like
GameObject.Destroy(GameObject.Find("TextureBufferCamera"));

Getting Movement with Google Cardboard in Unity

I want to put a scene in Unity into virtual reality using Google Cardboard.
I used to be able to just drag a CardboardMain prefab into the scene, delete the main camera, use CardboardMain as the camera position, and CardboardHead to track where the user was looking.
After reading the release notes for the new updates, I thought I could drag a GVREditorEmulator and GVRControllerMain into the scene, and keep the normal camera.
Unfortunately, I can't figure out how to get the camera to follow my character with this new setup. (In this case, a rolling ball.)
If I change the position of the normal camera, it looks like it works fine in Unity, but as soon as I upload it to my phone, the user stays in the same place, while the ball rolls away. (The user can still control the ball's movements, but the camera/user doesn't follow the ball at all.)
I had thought that the chase cam demo would be useful, but that's only for Daydream, and I'm using Cardboard.
This trick seemed to work for some people. I tried in on a previous version of Unity and a previous version of the SDK and it did not seem to work. I may just need to try it on this new version, but I'm worried about going into the released code and editing it, so I'd prefer answers that don't require this.
Is there any way I can get the user to move in a Google Cardboard scene in Unity when I upload it to my iPhone?
UPDATE:
It looks as though my main camera object is not moving, making me think that something is resetting it back to the center every time, lending some more credence to the "trick" earlier. I will now try "the trick" to see if it works.
UPDATE: It doesn't look like the lines listed in the "trick" are there anymore, and the ones that are similar in the new program don't even seem to be running. Still trying to figure out what continues to reset the main camera's position.
UPDATE: Just got a response back from Google on GitHub (or at least someone working on the SDK) that says "You just need to make the node that follows the player a parent of the camera, not the same game object as the camera." I'm not exactly sure what that means, so if someone could explain that, that would most likely solve my problem. If I figure it out on my own I'll post back here.
UPDATE: Zarko Ristic posted an answer that explained what this was, but unfortunately the tracking is still off. I found out how to get Google Cardboard to work with the old SDK and posted an answer on that. Still looking for ways to get the new SDK to follow a character properly.
You can't change positioin of camera in cardboard application, position of MainCamera it always must be 0,0,0. But you can just simply made empty GameObject and make it parent of MainCamera. In Cardboard games actualy you can move parent of camera instead MainCamera directly.
Add script for tracking ball to MainCamera parent (GameObject).
This does not answer my question, but is a solution to the problem.
Do not use the newest version of the SDK. Use version 0.6
When building the app in Unity, do not select to have VR enabled under the build settings. (VR will still be enabled in the app.) (Credit: Zarko Ristic)
When putting the app onto your phone, if XCode prompts you to change any settings, you can ignore it.
In addition, disable bitcode under "Build Settings -> Enable Bitcode -> No" (Currently, this will not allow you to put your app onto the app store. I would greatly appreciate it if anyone has information on how to get it to run without doing this.)
Now your app should run on your phone correctly.

Combining Windows Forms and XNA, but lacks "Game" instance

I am currently working on a Map Editor for my 3D game, but I am having some problems getting the using Microsoft.Xna.Framework.Game included.
My 3D engine is stored in a library, and the constructor for it needs the Game instance and a GraphicsDevice.
The GraphicsDevice is not a problem since i used some example from App Hub (link text), but using the "Game" is not included in it. Does anyone know how I would fix this? Thanks :)
Pretty much the entire point of the WinForms sample is to remove the use of Game (and the Microsoft.Xna.Framework.Game assembly). The Game class does things that you probably do not want to have happen within your editor.
I would recommend modifying your 3D engine so that it does not require an instance of the Game class, in order to be created.
What are you using from Game, anyway? A ContentManager, perhaps? Just pass that in directly.
But if you really must reference the Game class, add a reference to the Microsoft.Xna.Framework.Game assembly to your project. Do this by right clicking the project in the solution explorer, selecting Add Reference and finding it in the list of .NET assemblies. Make sure you get correct version.
I too am writing a 3D engine in XNA, called 'Vanquish'
Now that I've seen your constructor, you need to remove the Game variable from this. Create a public static variable called Instance in your Engine. Then, in your constructor add the following:
Instance = this;
From your WinForm application, whenever you need to use Game you can use engine.Instance.

Categories