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.


Topics - DanRP

Pages: [1]
1
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:

Code: [Select]
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:
Code: [Select]
oGameObject = tk2dSprite.CreateFromTexture( oTexture, tkCollectionSize, tSize, tAnch );
Code: [Select]
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

Pages: [1]