Beispiel #1
0
        public Sprite GetSprite(string name)
        {
            AFTextureInfo txInfo = m_texturesInfo[name];

            if (txInfo == null)
            {
                UnityEngine.Debug.LogWarning("THE SPRITE WAS NOT FOUND: " + name);
                return(null);
            }

            Sprite L_sprite;

            if (txInfo.GetSprite() == null)
            {
                L_sprite = Sprite.Create(
                    m_texture,
                    txInfo.GetFrame(),
                    txInfo.GetPivot(),
                    100.0f);

                txInfo.SetSprite(L_sprite);
            }
            else
            {
                L_sprite = Instantiate(txInfo.GetSprite()) as Sprite;
            }

            return(L_sprite);
        }
Beispiel #2
0
        private void ParseCVSFile(String path)
        {
            UnityEngine.Debug.Log("PATH: " + Application.dataPath + "/Resources/" + path);

            if ((Path.GetExtension(Path.GetExtension(path)) == ""))
            {
                path += ".aff";
            }

            AFCsvFileReader reader = new AFCsvFileReader(Application.dataPath + "/Resources/" + path);
            AFCsvRow        row    = new AFCsvRow();
            AFTextureInfo   info   = null;

            UnityEngine.Rect    rect;
            UnityEngine.Vector2 pivot = UnityEngine.Vector2.zero;

            float x  = 0.0f;
            float y  = 0.0f;
            float w  = 0.0f;
            float h  = 0.0f;
            float px = 0.0f;
            float py = 0.0f;

            string name;

            while (reader.ReadRow(row))
            {
                info = new AFTextureInfo();

                name = row[0].Replace("/", "_");

                x  = float.Parse(row[1]);
                y  = float.Parse(row[2]);
                w  = float.Parse(row[3]);
                h  = float.Parse(row[4]);
                px = float.Parse(row[5]);
                py = float.Parse(row[6]);

                rect  = new UnityEngine.Rect(x, y, w, h);
                pivot = new UnityEngine.Vector2(px, py);

                //TODO: Verificar bounds no sprites
//                 UnityEngine.Debug.Log("---------------------");
//                 UnityEngine.Debug.Log("Name: " + name);
//                 UnityEngine.Debug.Log("Rect: " + rect);
//                 UnityEngine.Debug.Log("Pivot: " + pivot);
//                 UnityEngine.Debug.Log("---------------------");

                info.SetName(name);
                info.SetFrame(rect);
                info.SetPivot(pivot);

                AddTextureInfo(info);
            }
        }
Beispiel #3
0
 private void AddTextureInfo(AFTextureInfo info)
 {
     m_texturesInfo[info.GetName()] = info;
 }