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 - aninocoders

Pages: [1]
1
Support / 2.0 Migration for Atlas Generation API
« on: August 19, 2013, 08:35:29 am »
Hello,

Our atlas generator no longer works in 2.1. API changes to tk2dSpriteCollection is not specified anywhere in the Migration Guide. This is the code that no longer compiles:


        private void CreateSpriteCollection(Dictionary<string, string> idAssetsPathMap) {
         // create game object with sprite collection
         GameObject go = new GameObject(spriteCollectionName);
         tk2dSpriteCollection collection = go.AddComponent<tk2dSpriteCollection>();
         collection.version = tk2dSpriteCollection.CURRENT_VERSION;
         
         UnityEngine.Object p = PrefabUtility.CreateEmptyPrefab(spriteCollectionPath);
           GameObject collectionPrefabGo = PrefabUtility.ReplacePrefab(go, p, ReplacePrefabOptions.ConnectToPrefab);
         tk2dSpriteCollection collectionFromPrefab = collectionPrefabGo.GetComponent<tk2dSpriteCollection>();
         GameObject.DestroyImmediate(go);
         
         // prepare collection parameters
         collectionFromPrefab.textureParams = new tk2dSpriteCollectionDefinition[idAssetsPathMap.Count];
         collectionFromPrefab.targetHeight = dataManager.ScreenHeight;
         collectionFromPrefab.targetOrthoSize = 1.0f;
         collectionFromPrefab.maxTextureSize = 2048;
         collectionFromPrefab.forceSquareAtlas = true;
         collectionFromPrefab.textureCompression = this.textureCompression;
         collectionFromPrefab.allowMultipleAtlases = true;
         
         // add textures to the collection
         int i = 0;
         foreach(KeyValuePair<string, string> entry in idAssetsPathMap) {
            Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(entry.Value, typeof(Texture2D));
            
            collectionFromPrefab.textureParams = new tk2dSpriteCollectionDefinition();
            collectionFromPrefab.textureParams.name = entry.Key;
            collectionFromPrefab.textureParams.colliderType = tk2dSpriteCollectionDefinition.ColliderType.ForceNone;
            collectionFromPrefab.textureParams.texture = texture;
            
            ++i;
         }
         
         tk2dSpriteCollectionBuilder.Rebuild(collectionFromPrefab);
      }


tk2dSpriteCollection.targetHeight (and some others) are no longer public and there's no property or setter that we can use. How do we fix this?

2
Support / When is the combined mesh generated?
« on: June 03, 2013, 09:51:51 am »
We have an overlay sprite that we fade-in/fade-out whenever we change levels. This is just a simple interpolation of the alpha color and set it unto the sprite. This overlay is implemented as a non destroyable object that persists. What happens is that somehow a combined mesh ("Combined Mesh (root:scene)") is assigned to the MeshFilter of the sprite when the next level is loaded. So whatever color assigned to it no longer changes the color of the sprite.

I don't want this happening. How do I prevent it? It happens automatically.

3
Support / Create Sprite Collections With Code
« on: April 24, 2013, 07:54:15 am »
Hello Unikron,

I'm building a Unity parser for another game engine. The game engine spouts XML files that we can read. Basically, the whole game can be constructed from these files.

I'm working on a Unity editor for this. The editor will ask for the folder of the XML files, parse these, copy image files, and create game objects on click of a button. Right now, I'm stuck on how to create Sprite Collections with code. Is this possible? I've rummaged through the 2D Toolkit source code. I can see how it goes from Open Editor... I just can't get the code flow when doing it without the editor.

Pages: [1]