void CheckForCopyPasting() { if (transitions.Length > 0) { if (transitions[0] != null && !transitions[0].parent.Equals(this))//if the transitions parent isn't this object then this object has been copy pasted { BaseTransition temp = null; System.Type type; for (int i = 0; i < transitions.Length; i++) { type = transitions[i].GetType(); if (type.Equals(typeof(AlphaTransition))) { temp = gameObject.AddComponent <AlphaTransition>();//make a correct instance } else if (type.Equals(typeof(MovingTransition))) { temp = gameObject.AddComponent <MovingTransition>(); } else if (type.Equals(typeof(ScalingTransition))) { temp = gameObject.AddComponent <ScalingTransition>(); } else if (type.Equals(typeof(ColourTransition))) { temp = gameObject.AddComponent <ColourTransition>(); } else if (type.Equals(typeof(RotatingTransition))) { temp = gameObject.AddComponent <RotatingTransition>(); } else { temp = gameObject.AddComponent <BaseTransition>();//these are for manual transitions } if (temp != null) { temp.Clone(transitions[i]);//copy the other data temp.parent = this; temp.hideFlags = HideFlags.HideInInspector; transitions[i] = temp; } } } } }
void CheckForCopyPasting() { #region Check if selected bool selected = false; if (Selection.gameObjects != null) { for (int i = 0; i < Selection.gameObjects.Length; i++) { if (Selection.gameObjects[i].Equals(gameObject))//if selected { selected = true; break; } } } if (Selection.activeGameObject != null) { if (Selection.activeGameObject.Equals(gameObject)) { selected = true; } } if (!selected) { return; } #endregion if (transitions.Length > 0) { if (transitions[0] != null && !transitions[0].parent.Equals(this))//if the transitions parent isn't this object then this object has been copy pasted { BaseTransition temp = null; System.Type type; for (int i = 0; i < transitions.Length; i++) { type = transitions[i].GetType(); if (type.Equals(typeof(AlphaTransition))) { temp = gameObject.AddComponent <AlphaTransition>();//make a correct instance } else if (type.Equals(typeof(MovingTransition))) { temp = gameObject.AddComponent <MovingTransition>(); } else if (type.Equals(typeof(ScalingTransition))) { temp = gameObject.AddComponent <ScalingTransition>(); } else if (type.Equals(typeof(ColourTransition))) { temp = gameObject.AddComponent <ColourTransition>(); } else if (type.Equals(typeof(RotatingTransition))) { temp = gameObject.AddComponent <RotatingTransition>(); } else { temp = gameObject.AddComponent <BaseTransition>();//these are for manual transitions } if (temp != null) { Debug.LogError("Added transitions to: " + gameObject + " Parent:" + transitions[0].parent + " " + (transitions[0].parent.GetHashCode() == GetHashCode())); temp.Clone(transitions[i]);//copy the other data temp.parent = this; temp.hideFlags = HideFlags.HideInInspector; transitions[i] = temp; } } } } }