Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Sasuga

Pages: [1]
1
Support / How can I compare actual sprites?
« on: October 17, 2013, 05:45:51 am »
Code: [Select]
using UnityEngine;
using System.Collections;

public class TestSprites : MonoBehaviour {
public tk2dSprite thisSprite;
public string spriteName;
public string objectName;

void Awake(){
thisSprite = gameObject.GetComponent<tk2dSprite>();
}

// Use this for initialization
void Start () {
//Sprite image name: mySprite
//Game object's name: myObject
thisSprite.SetSprite(1);
spriteName = thisSprite.name;
objectName = gameObject.name;
if(spriteName == objectName)
Debug.Log ("They're the same!");
else
Debug.Log ("They're not the same!");
}

When I run the above code my Console says:
Code: [Select]
They're the same!
UnityEngine.Debug:Log(Object)
TestSprites:Start() (at Assets/TestSprites.cs:21)

I don't see any place in the scripting reference to get the name of the sprite/image out as a string for tk2dSprite and I've tried searching the web.  If it exists can someone point me to it?  If it doesn't, can it please get added?

I'd like to be able to allow people to scroll through a list of sprites and display their names below them.
I'd like to be able to check if a sprite's name matches against a string for things like bug checking.

I'm sure being able to get the name out is useful for other things as well.

I'd like to be able to put the SpriteID in and get the Sprite's name out.
In case there's confusion, the string I'm looking for is the one that appears in the drop-down-menu next to "Sprite" which is under "Collection" in the "Tk 2d Sprite (Script)" component.

Thanks,
Sasuga

Pages: [1]