public static void Revert() { print("Start replacing any AnubisInputFieldTMP to TMP_InputFields"); int i = 0; foreach (var aif_InputField in FindAllObjectsOfTypeExpensive <AnubisInputField>().ToList()) { var inputFieldGo = aif_InputField.gameObject; var tempInputField = new GameObject().AddComponent <AnubisInputField>(); EditorUtility.CopySerialized(aif_InputField, tempInputField); DestroyImmediate(aif_InputField); ComponentUtil.CopyPastSerialized(tempInputField, inputFieldGo.AddComponent <TMP_InputField>()); DestroyImmediate(tempInputField.gameObject); print("Replaced: " + inputFieldGo.name); i++; } print("Successfully Replaced " + i + " Anubis Input Fields"); }
public static void Convert() { print("Start replacing any TMP_InputField to AnubisInputFieldTMP"); int i = 0; //For each TMP_Input field in the loaded scene foreach (var tmp_InputField in FindAllObjectsOfTypeExpensive <TMPro.TMP_InputField>().ToList()) { var inputFieldGo = tmp_InputField.gameObject; //Creating a tmp gameobj to hold the same serialized properties of current TMP_InputField script, //as we cannot AddComponent of an AnubisInputField script while TMP_InputField script still attached to gameobj var tmpGoTMP_InputField = new GameObject().AddComponent <TMP_InputField>(); //Copy and paste serialized properties of current TMP_InputField script to temp gameobj TMP_InputField script EditorUtility.CopySerialized(tmp_InputField, tmpGoTMP_InputField); //Remove TMP_InputField script, to replace with AnubisInputField DestroyImmediate(tmp_InputField); //Create AnubisInputField and paste TMP_InputField serialized properties ComponentUtil.CopyPastSerialized(tmpGoTMP_InputField, inputFieldGo.AddComponent <AnubisInputField>()); //Remove tempGo as its not needed anymore DestroyImmediate(tmpGoTMP_InputField.gameObject); print("Replaced: " + inputFieldGo.name); i++; } print("Successfully Replaced " + i + " TMP Input Fields"); }