public IGPUAnim Instantiate(GameObject prefab, Vector3 pos, Quaternion rot)
 {
     if (supportsInstancing)
     {
         GPUAnimGroup group = null;
         GroupDic.TryGetValue(prefab.name, out group);
         if (group == null)
         {
             GameObject o = GameObject.Instantiate(prefab, transform);
             o.name = prefab.name;
             GPUAnimation gpuAnim = o.GetComponentInChildren <GPUAnimation> ();
             gpuAnim._gameObject = o;
             group = new GPUAnimGroup(gpuAnim);
             GroupDic.Add(o.name, group);
             o.SetActive(false);
             // DestroyImmediate (o);
         }
         var animObj = new GPUAnimObj(pos, rot);
         group.AddObject(animObj);
         return(animObj as IGPUAnim);
     }
     else
     {
         GameObject   o       = GameObject.Instantiate(prefab, pos, rot);
         GPUAnimation gpuAnim = o.GetComponentInChildren <GPUAnimation> ();
         // if (!gpuAnim) return o.GetComponent<GPUAnim_> ();
         gpuAnim._gameObject = o;
         return(gpuAnim as IGPUAnim);
     }
 }
Ejemplo n.º 2
0
 public GPUAnimGroup(GPUAnimation o)
 {
     this.prefab   = o._gameObject;
     this.mesh     = o.mesh;
     this.material = o.material;
     this.animCfg  = o.animCfg;
     GPUAnimUtility.Instance.SetupMesh(mesh);
 }
Ejemplo n.º 3
0
 public override void OnInspectorGUI()
 {
     go = (GPUAnimation)target;
     base.OnInspectorGUI();
     if (GUILayout.Button("Play Next: " + clip))
     {
         if (cfg == null)
         {
             cfg = go.animCfg;
         }
         if (Idx >= cfg.AnimClips.Count - 1)
         {
             Idx = 0;
         }
         if (clip != null)
         {
             go.Play(clip);
         }
         clip = cfg.AnimClips[Idx++].clipName;
     }
 }