Hello Everyone,
I'm just getting started with exporting for Windows Store / Windows 8 and I'm getting a run-time error that I can't figure out. Here's the code:
GameObject oGameObject = null;
Texture2D oTexture = null;
oTexture = Resources.Load( pFilename, typeof(Texture2D) ) as Texture2D;
if (!ReferenceEquals(oTexture, null)) {
Rect tSize = new Rect(0, 0, oTexture.width, oTexture.height);
Vector2 tAnch = new Vector2( oTexture.width * OffsetX, oTexture.height * (1.0f - OffsetY));
tk2dSpriteCollectionSize tkCollectionSize = tk2dSpriteCollectionSize.ForTk2dCamera();
oGameObject = tk2dSprite.CreateFromTexture( oTexture, tkCollectionSize, tSize, tAnch );
oSprite = oGameObject.GetComponent<tk2dSprite>();
}
I'm getting an error on this line:
oGameObject = tk2dSprite.CreateFromTexture( oTexture, tkCollectionSize, tSize, tAnch );
Exception: Object reference not set to an instance of an object.
InnerException:
AdditionalInfo:
at tk2dSprite.Awake() in c:\data\Games\StackTheStatesUnity\Assets\TK2DROOT\tk2d\Code\Sprites\tk2dSprite.cs:line 25
at tk2dSprite.UnityFastInvoke_Awake()
Here's what I know:
1) When I Debug.Log my oTexture object, it shows as "BaseObject: NotAvailableDuringDebugging"
2) I know the resource is being loaded because the width and height properties are correct (100)
3) This code works perfectly when exporting to android and iOS
4) I'm using 2D Toolkit version 2.1 final and Unity 4.2
It seems that something is wrong with my oTexture object when exporting for Windows Store...
Can anyone help me figure out why this code is failing?
Thanks!
Dan