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); } }
public GPUAnimGroup(GPUAnimation o) { this.prefab = o._gameObject; this.mesh = o.mesh; this.material = o.material; this.animCfg = o.animCfg; GPUAnimUtility.Instance.SetupMesh(mesh); }
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; } }