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 InstancingBatch(GPUAnimGroup group) { this.group = group; property = new GPUAnim.MaterialProperty(MAXBATCHCOUNT); }