1
Support / Re: Sprite Collection Analysis at Run Time
« on: April 10, 2013, 03:24:32 pm »
No dice...ing.
By which I mean, cool, thanks!
By which I mean, cool, thanks!
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.
Vector2 spriteUVSize= new Vector2(
Mathf.Abs(spriteDef.uvs[0].x - spriteDef.uvs[spriteDef.uvs.Length-1].x),
Mathf.Abs(spriteDef.uvs[0].y - spriteDef.uvs[spriteDef.uvs.Length-1].y)
);
spriteUseMemory += (int)((spriteUVSize.x *textureSize.x ) * (spriteUVSize.y * textureSize.y));
NullReferenceException: Object reference not set to an instance of an object
tk2dBaseSprite.SetColors (UnityEngine.Color[] dest) (at Assets/TK2DROOT/tk2d/Sprites/tk2dBaseSprite.cs:169)
tk2dSprite.UpdateColorsImpl () (at Assets/TK2DROOT/tk2d/Sprites/tk2dSprite.cs:71)
tk2dSprite.UpdateColors () (at Assets/TK2DROOT/tk2d/Sprites/tk2dSprite.cs:65)
tk2dBaseSprite.set_color (Color value) (at Assets/TK2DROOT/tk2d/Sprites/tk2dBaseSprite.cs:27)
BaseUnit.OnSpawned () (at Assets/Scripts/Gameplay/Units/BaseUnit.cs:131)
public public Renderer sprite;//Points to a child of this object with the sprite on it: i always do this to allow for model orientation independence.
internal tk2dAnimatedSprite anim;
void Awake () { Init(); }//Call a virtual for inheritance hacking: can't use overrides on any of unity's built in component functions
internal virtual void Init() //Called first time the object is ever run. Only need to be done once.
{
...
anim = sprite.gameObject.GetComponent<tk2dAnimatedSprite>();
}
void OnEnable() { OnSpawned(); }//just call a virtual version
internal virtual void OnSpawned()
{
...
anim.Play(0);
anim.color = Color.white.Transparency(0.5f);//crashes here. The Transparency call just returns the same color, but with the given parameter replacing alpha.
}