Ejemplo n.º 1
0
    public void Reset(GpuInstancedAnimation animation, int offsetFrame)
    {
        mAnimation = animation;

        mOffsetFrame  = offsetFrame;
        mCurrentFrame = 0;
        mCurrentTime  = 0;
    }
Ejemplo n.º 2
0
 private void OnEnable()
 {
     if (instancedAnimation == null)
     {
         instancedAnimation = GetComponent <GpuInstancedAnimation>();
     }
     if (instancedAnimation == null)
     {
         return;
     }
     instancedAnimation.onAnimationClipBegin += OnAnimationClipBegin;
     instancedAnimation.onAnimationClipEnd   += OnAnimationClipEnd;
 }
Ejemplo n.º 3
0
    void InstantiateObject()
    {
        for (int i = 0; i < Count; ++i)
        {
            Vector2 v = Random.insideUnitCircle * radius;

            GameObject prefab = Prefabs[Count == 1 ? 0 : Random.Range(0, Prefabs.Count)];

            GameObject go = Instantiate(prefab) as GameObject;
            go.transform.position = Count == 1?new Vector3(0, 5, -10): new Vector3(v.x, 0, v.y);
            go.SetActive(true);

            if (Controll && Count == 1)
            {
                samplePlay = go.AddComponent <SamplePlay>();
            }
            if (Rotate && Count == 1)
            {
                go.AddComponent <SampleRotate>();
            }

            SamplePlayEffect samplePlayEffect = go.GetComponent <SamplePlayEffect>();
            if (samplePlayEffect != null)
            {
                samplePlayEffect.enabled = ShowEffect && Count == 1;
            }

            GpuInstancedAnimation animation = go.GetComponent <GpuInstancedAnimation>();

            int index          = Random.Range(0, animation.animationClips.Count);
            var animationFrame = animation.animationClips[index];
            animation.speed = Count == 1? 1: Random.Range(0.5f, 3);
            animation.Play(animationFrame.Name);

            mUpdateList.Add(animation);

            if (Count == 1)
            {
                controllAnimation = animation;
            }
            if (Count > 1)
            {
                foreach (var clip in animation.animationClips)
                {
                    clip.wrapMode = GpuInstancedAnimationClip.WrapMode.Loop;
                }
            }
        }
    }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     mAnimation = GetComponent <GpuInstancedAnimation>();
 }