Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        _animMeta = CocoResMgr.GetAnimMeta(anim_id);
        if (_animMeta != null)
        {
            metaDatas = new List <CocoMetaData>();
            foreach (int id in _animMeta.components)
            {
                metaDatas.Add(CocoResMgr.GetMetaData(id));
            }

            _cocoRenderers = new List <CocoRenderer>(_animMeta.components.Count);
            for (int i = 0; i < _animMeta.components.Count; i++)
            {
                var comId = _animMeta.components[i];
                var meta  = CocoResMgr.GetMetaData(comId);
                if (meta != null)
                {
                    if (meta is CocoSpritaMeta)
                    {
                        var spritePrefab = Resources.Load <GameObject>("CocoSpriteRenderer");
                        var go           = Instantiate(spritePrefab, this.transform);
                        go.name = "sprite_" + meta.id;
                        var spriteRenderer = go.GetComponent <CocoSpriteRenderer>();
                        spriteRenderer.SetSpriteId(meta.id);
                        _cocoRenderers.Add(spriteRenderer);
                    }
                    else
                    {
                        var animPrefab = Resources.Load <GameObject>("CocoAnimator");
                        var go         = Instantiate(animPrefab, this.transform);
                        go.name = "anim_" + meta.id;
                        var animator = go.GetComponent <CocoAnimatior>();
                        animator.anim_id = meta.id;
                        animator.fps     = fps;
                        _cocoRenderers.Add(animator);
                    }
                }
            }
        }
        curFrame = 0;
        Play(curFrame);
    }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     _animMeta = CocoResMgr.GetAnimMetaByName(anim_name);
     animators = new List <CocoRenderer>(count);
     Gen();
 }