I'm having trouble getting this to work properly. I'm new to Unity/2D Toolkit and moving my project over from FlatRedBall, where I did everything in code. In that, I had created a method which outputted a solid Texture2D to be used for a sprite. I created this so I could easily throw together overlays and fades of any color. Here is the method:
public Texture2D GetSolidTexture(Color C)
{
Texture2D _SolidTexture = new Texture2D(64, 64, TextureFormat.RGBA32, false, false);
Color[] _C = new Color[_SolidTexture.width * _SolidTexture.height];
for (int i = 0; i < _C.Length; i++)
{ _C[i] = C; }
_SolidTexture.SetPixels(_C);
return _SolidTexture;
}
I had it at 2x2 so it would take up as little space as possible, but I changed it to 64x64 so it would be visible for testing.
Here is me trying to create the sprite, a black overlay that I'll be fading out:
GameObject _BlackOverlay = tk2dSprite.CreateFromTexture(GetSolidTexture(new Color(0f, 0f, 0f, 1f)), tk2dSpriteCollectionSize.Explicit(576f, 64f), new Rect(0f, 0f, 64f, 64f), new Vector2(0f, 0f));
tk2dSprite _BlackOverlaySprite = _BlackOverlay.GetComponent<tk2dSprite>();
_BlackOverlaySprite.SortingOrder = 5;
_BlackOverlaySprite.scale.Set(32f, 18f, 1f);
_BlackOverlaySprite.transform.Translate(-1024f, 576f, 0f);
I'm not using tk2dCamera. The base size seems to be fine (still getting used to this ortho+height thing...), but scale.Set fails to change it. The texture color is also incorrect, instead of solid black it is transparent white. Can anyone figure out what I'm doing wrong?