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.


Messages - hizral84

Pages: [1]
1
Support / 2D Toolkit Atlas, How can I used it with my script.
« on: September 20, 2013, 03:05:51 am »
Hello there,

This just purchase 2D Toolkit and this is my first time using it. I would like make a number counter using the 2D toolkit. Usually I used a sprite atlas that I made my self for the number zero to nine and just assign the coordinates manually. Below here is the script that I alwayt used for the number sprites:

Code: [Select]
    using UnityEngine;
    using System.Collections;
     
    public class TestManager : MonoBehaviour {
       
        public int testScore; //If the testScore is increasing it will move the coordinates to the next sprites.
        public GameObject score;
       
        // Use this for initialization
        void Start ()
        {
       
        }
       
        // Update is called once per frame
        void Update ()
        {
            if (score != null)
            {
                //TextSprite (score, 10, 0, 10, "fScore", testScore);
            }
           
           
        }
                       
        void TextSprite (GameObject spriteObject, int columSize, int colFrameStart, int totalFrame, string type, int index)
        {
            int fScore;
           
            fScore = index % 10;
           
            if (type == "fScore")
            {
                index = fScore;
            }
           
            index = index % columSize;
           
            Vector2 offSet;
            offSet = new Vector2 (1.0f / columSize * index, 0);
            spriteObject.renderer.material.mainTextureOffset = offSet;
        }
    }

so now when I create a power of two from the 2D toolkit option and used my script it does not work why is that?

Thank you.

Pages: [1]