- Home /
PackedSprite object returning null
 public GameObject pad; //Assigned through the viewer
 
 PackedSprite sprite; //Null
  
  public void create()
  {
  print(pad.name); // Pad is working perfectly
  sprite = pad.GetComponent<PackedSprite>() as PackedSprite; //This is run without an error
         sprite.PlayAnim(0); // Returns an error
  
  }
I am using Sprite Manager 2 and I am having trouble affecting the sprite. I am setting pad through the Inspector but I do not know how to assign the PackedSprite, so I tried doing it via code. Every time I try to use sprite it returns:
 NullReferenceException: Object reference not set to an instance of an object
Any suggestions on how to prevent this?
               Comment
              
 
               
              Are you sure that pad has a PackedSprite component attached? It could be missing, or attached to a child GameObject, for example. GetComponent() will return null if no component of the requested type is found. 
Yes it is. http://i.imgur.com/3uO6$$anonymous$$.png O1 is assigned to pad (confirmed 100%)
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                