14
« on: June 17, 2012, 12:43:34 pm »
Thanks, some quick questions thou...
How do I get hold of the "spriteCollectionData"? I'm not sure exactly how it works in Unity getting hold of stuff, or is it depending on which object the script is added onto? Now it's added to the camera since it should run in the beginning of the scene.
Then I can't find the "AddComponent" function, and I have 1.7 + patch 2, is it in the new beta one?
And when I use AddComponent should I use it as I have in the code below?
using UnityEngine;
using System.Collections;
public class StartScript : MonoBehaviour {
tk2dSprite sprite;
// Use this for initialization
void Start () {
var spriteCollectionData = GetComponent<tk2dSpriteCollectionData>();
var boundsData = spriteCollectionData.FirstValidDefinition.untrimmedBoundsData;
Bounds bounds = new Bounds(boundsData[0], boundsData[1]);
GameObject go = new GameObject();
//go.transform.position = new Vector3(bounds.extents.x*2*
sprite.AddComponent(go, spriteCollectionData, "lamp");
}
// Update is called once per frame
void Update () {
}
}
Then I have one un-related question. I use a tk2dCamera but I can't really find where to set the resolution so the game preview window shows in the correct resolution, thou it looks correct in the scene window, the camera bounds is exactly covering the whole background I have. Even if I added a "2048x1536" option in the build setting and using "Standalone(2048x1536)" in the game preview window I only get a really close up view of my scene when I should be able to see the whole background which have the size 2048x1536.