public override void Draw() { #if PSR_FULL GUILayout.BeginHorizontal(); float lw = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = SRWindow.compactLabelWidth; UnityEngine.Object newValue = EditorGUILayout.ObjectField(Keys.Replace, replaceValue.obj, typeof(UnityEngine.Object), true); EditorGUIUtility.labelWidth = lw; // i love stateful gui! :( if(replaceValue.obj != newValue) { UnityEngine.Object scriptObject = ObjectUtil.getScriptObjectFromObject(newValue); if(scriptObject == null && newValue != null) { //looks like we couldn't get an object! Debug.Log("[Project Search & Replace] "+newValue+" isn't a Component, MonoBehaviour, ScriptableObject or MonoScript."); } setObject(scriptObject); SRWindow.Instance.PersistCurrentSearch(); } if(type != null) { GUILayout.Label("("+type.Name+")"); drawSwap(); GUILayout.EndHorizontal(); if(parent.type != null) { bool isMB = typeof(MonoBehaviour).IsAssignableFrom(type); bool isParentMB = typeof(MonoBehaviour).IsAssignableFrom(parent.type); bool isScript = typeof(ScriptableObject).IsAssignableFrom(type); bool isParentScript = typeof(ScriptableObject).IsAssignableFrom(parent.type); if( (isMB && isParentMB) || (isScript && isParentScript)) { if(parent.type.IsAssignableFrom(type)) { replaceValid = true; // EditorGUILayout.HelpBox("Looks good!", MessageType.Info); }else{ replaceValid = true; EditorGUILayout.HelpBox("Inheritance Warning: These classes do not inherit from each other but Unity will attempt to merge data as best as possible.", MessageType.Info); } } else { replaceValid = false; EditorGUILayout.HelpBox("Invalid or Mixed Parameters. Components can only be searched for, not replaced.", MessageType.Warning); } } }else{ replaceValid = false; drawSwap(); GUILayout.EndHorizontal(); } #endif }
public override void Draw(SearchOptions options) { float lw = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = SRWindow.compactLabelWidth; GUILayout.BeginHorizontal(); UnityEngine.Object newValue = EditorGUILayout.ObjectField("Value:", searchValue.obj, typeof(UnityEngine.Object), true); EditorGUIUtility.labelWidth = lw; // i love stateful gui! :( if (newValue != searchValue.obj) { UnityEngine.Object scriptObject = ObjectUtil.getScriptObjectFromObject(newValue); if (scriptObject == null && newValue != null) { //looks like we couldn't get an object! Is it a directory? if (ObjectUtil.IsDirectory(newValue)) { setFolder(newValue); } else { Debug.Log("[Project Search & Replace] " + newValue + " isn't a Folder, Component, MonoBehaviour, ScriptableObject or MonoScript."); } } else { SetObject(scriptObject); } SRWindow.Instance.PersistCurrentSearch(); } if (type != null) { GUILayout.Label("(" + type.Name + ")"); } GUILayout.EndHorizontal(); if (searchValue.isDirectory) { GUILayout.BeginHorizontal(); GUILayout.Space(SRWindow.compactLabelWidth + 4); bool newShowUnused = EditorGUILayout.ToggleLeft("Show Unused Scripts", showUnusedScripts); GUILayout.EndHorizontal(); if (newShowUnused != showUnusedScripts) { showUnusedScripts = newShowUnused; SRWindow.Instance.PersistCurrentSearch(); } } if (showMoreOptions) { if (SRWindow.Instance.Compact()) { GUILayout.BeginHorizontal(); GUILayout.Space(SRWindow.compactLabelWidth); } if (!searchValue.isDirectory) { GUILayout.BeginHorizontal(); GUILayout.Space(SRWindow.compactLabelWidth + 4); bool newMatchChildClasses = EditorGUILayout.ToggleLeft("Match Child Classes?", matchChildClasses); GUILayout.EndHorizontal(); if (newMatchChildClasses != matchChildClasses) { matchChildClasses = newMatchChildClasses; SRWindow.Instance.PersistCurrentSearch(); } } if (SRWindow.Instance.Compact()) { GUILayout.EndHorizontal(); } } drawReplaceItem(options); }