// Initializes the clones for the Warp trick. protected virtual void Initialize() { _collider = GetComponent <Collider>(); _renderer = GetComponentInChildren <MeshRenderer>(); _wcScript = GetComponent <WarpClone>(); _wcScript.OnCloned = OnClonesLoaded; _wcScript.Clone(); }
public void Clone() { // Only clone if it's not a clone itself. if (!IsClone) { GameObject newClone = GameObject.Instantiate(gameObject); newClone.SetActive(false); newClone.GetComponent <WarpClone>().IsClone = true; _cloneIndex = GameManager.Instance.RegisterClone(gameObject, newClone); // Apply index to all the cloned objects. foreach (GameObject obj in GetClones()) { WarpClone wc = obj.GetComponent <WarpClone>(); wc.SetCloneIndex(_cloneIndex); } OnCloned(); } }