2D Toolkit Forum
2D Toolkit => Support => Topic started by: Xaron on September 06, 2016, 09:24:25 am
-
Dear all,
I have a strange problem with a prefab. It's a tk2d text prefab which has a tk2dcameraanchor attached to it. This anchor has a public variable called "Camera". Everytime I restart Unity (5.4) this prefab loses the camera variable. Is there a solution to that?
Please take a look at the attached screenshots. Thanks!
-
Hi there,
Where is this variable? Is it in the scene?
The asset is in the project folder, so it won't be able to retain a link to anything that is in the scene...
-
Hi,
yes it's in the scene. Hmm I see.
I just add inside the Start() method now:
_tk2dCamera = GameObject.Find( "tk2dCamera" ).GetComponent<Camera>();
_textAnchor.transform.parent = _tk2dCamera.transform;
_textAnchor.AnchorCamera = _tk2dCamera;
Thanks!
-
Am I wrong that you can call tk2dCamera.Instance in code to get a reference to your camera?
_tk2dCamera = tk2dCamera.Instance;
_textAnchor.transform.parent = _tk2dCamera.transform;
_textAnchor.AnchorCamera = _tk2dCamera;
-
That should work fine as long as you're not using viewport clipping.