public static void ReplaceWithComponent(GameObject target, Type org, Type mp_version, bool addToPhotonView = false) { if (!target.GetComponent(org)) { return; } Component orgComp = target.GetComponent(org); Component newComp = null; if (!target.GetComponent(mp_version)) { target.AddComponent(mp_version); } newComp = target.GetComponent(mp_version); List <string> skips = E_Helpers.CopyComponentValues(orgComp, newComp); DestroyImmediate(orgComp); if (addToPhotonView == true) { AddCompToPhotonView(target, newComp); } }
public static void CB_CONTEXT_PASTE(MenuCommand command) { if (CB_COMP_COPY == null) { if (EditorUtility.DisplayDialog("No Source Component", "You don't have a source component targeted. First select \"Copy Component Values\" on the " + "component that you would like to copy.", "Okay")) { return; } } else { SerializedObject target = new SerializedObject(command.context); if (EditorUtility.DisplayDialog("Paste Copied Component?", "Would you like to paste \"" + CB_COMP_COPY.targetObject + "\" component's values to: \"" + target.targetObject + "\"?", "Yes", "No")) { E_Helpers.CopyComponentValues((Component)CB_COMP_COPY.targetObject, (Component)target.targetObject, true); } } }