Search Unity

How to assign SpriteText in scripting

Discussion in 'Scripting' started by Danim3D, Jul 24, 2011.

  1. Danim3D

    Danim3D

    Joined:
    Sep 7, 2009
    Posts:
    18
    I want to assign SpriteText in script like we can do with GameObject but the Find fonction doesn't work with SpriteText.

    With GameObject I can do this:
    Code (csharp):
    1. public GameObject SpawnPoint;
    2. SpawnPoint = GameObject.Find("SpawnPoint").transform.position;

    What is the syntax to do this with SpriteText
    Code (csharp):
    1. public SpriteText lifetext;
    2. lifetext = SpriteText.Find("PlayerLife");
     
    Last edited: Jul 24, 2011
  2. Eiznek

    Eiznek

    Joined:
    Jun 9, 2011
    Posts:
    374
    Just throwing a guess with no back up. Could you cast it to SpriteText after using the GameObject find.

    Code (csharp):
    1. lifeText = (SpriteText)GameObject.Find("PlayerLife");
     
  3. Danim3D

    Danim3D

    Joined:
    Sep 7, 2009
    Posts:
    18
    It doesn't work, I get this error because SpriteText are not considered as GameObject.

     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723