

M_CurrentActiveObject = nextactiveobject ĬamSwitchButton.text = objects. To add a GUIText component, you could write gameObject.AddComponent (GUIText) within your Start function. Int nextactiveobject = m_CurrentActiveObject + 1 >= objects.Length ? 0 : m_CurrentActiveObject + 1 using UnityEngine using UnityEngine. Use this to read or edit the message displayed in Text. active object starts from first in arrayĬamSwitchButton.text = objects.name This is the string value of a Text component. Public class SimpleActivatorMenu : MonoBehaviour How do I do that Here is my code: using UnityEngine using System. SceneManager.LoadScene(SceneManager.GetSceneAt(0).name) So I have a working timer attached to a GUIText but I can't display it in game. If (CrossPlatformInputManager.GetButtonDown("ResetObject")) Now select your GameObject with the Timer component and drag GO on the Timer Text field. Using UnityStandardAssets.CrossPlatformInput Create a GameObject GO, click Add Component -> Rendering -> GUIText. Now you should be able to access myTextLabel.text. Where you are declaring your public strings, add a line similar to this: public Text myTextLabel Next, drag and drop your UI Text element from the Hierarchy to the 'My Text Label' reference in the Inspector. Now my game mode will play!!! //ForcedReset.cs Ahh, after reading your other comment, I see you are using a UI Text instead of a GUIText. Where the originally suggested changes from GUITexture to UI.Texture and GUIText to UI.Text, I just removed the UI, as in the post link above! This adds a Canvas, a text object, and an event System to the hierarchy. In both SimpleActivatorMenu.cs and ForcedReset.cs paste the following at the top "using UnityEngine.UI " The Unity UI is a user interface development toolkit for games and applications. InvalidOperationException: Cannot start process because a file name has not been provided.Īssets/Standard Assets/Utility/SimpleActivatorMenu.cs(10,16): error CS0246: The type or namespace name 'UI' could not be found (are you missing a using directive or an assembly reference?)Īssets/Standard Assets/Utility/ForcedReset.cs(6,27): error CS0246: The type or namespace name 'UI' could not be found (are you missing a using directive or an assembly reference?) If the text isn’t visible when you press Play, check that the transform has suitable position, typically (0.5, 0.5, 0.0). When I was opening up those files - SimpleActivatorMenu.cs and ForcedReset.cs, and making the suggested changes of GUITexture to UI.Texture and GUIText to UI.Text i was getting the following errorsĮxception thrown while invoking method ':OnOpenAsset (int,int,int)' : InvalidOperationException: Cannot start process because a file name has not been provided. To add a GUIText component in Unity 5.0, first use GameObject->Create Empty to create an empty game object, then use the Component->Rendering->GUIText option to add the GUIText component to the newly created game object.

#UNITY UI TEXT AS TIMER GUITEXT UPDATE#
I WAS (this is an update I just fixed it!!) having the exact same problem.
