Esempio n. 1
0
        new void Awake()
        {
            base.Awake();

            //Load some things from resources
            swipeText      = (Resources.Load("GUI/Swipe Text") as GameObject).GetComponent <Text>();
            floatingText   = (Resources.Load("GUI/Floating Text") as GameObject).GetComponent <FloatingText>();
            attackArrow    = (Resources.Load("GUI/Attack Arrow") as GameObject).GetComponent <AttackArrow>();
            blockingSlider = (Resources.Load("GUI/Blocking Slider") as GameObject).GetComponent <BlockingSlider>();

            //Reference some things from the scene
            mainCanvas = GameObject.Find("Main Canvas").GetComponent <Canvas>();
        }
Esempio n. 2
0
        /// <summary>
        /// Displays some floating text around a game object.
        /// </summary>
        /// <param name="spawnPoint">Transform where the floating text will spawn.</param>
        /// <param name="textContents">Contents of the text.</param>
        public void DisplayFloatingText(Transform spawnPoint, string textContents, bool parentIsCanvas = true)
        {
            if (spawnPoint == null)
            {
                return;
            }

            //Create the text
            FloatingText text           = Instantiate(floatingText, mainCanvas.transform, false);
            Vector2      screenPosition =
                Camera.main.WorldToScreenPoint(new Vector2(spawnPoint.position.x + UnityEngine.Random.Range(-5.0f, 5.0f), spawnPoint.position.y + UnityEngine.Random.Range(0.0f, 5.0f)));

            //Set up the text
            text.transform.position = screenPosition;
            text.SetText(textContents);
        }