public static Vector3 DoPositionHandle(Vector3 position, Quaternion rotation, Action <Vector3> onChanged) { using (EditorGUIEx.ChangeCheck(() => onChanged(position))) { position = Handles.DoPositionHandle(position, rotation); return(position); } }
public static Quaternion DoRotationHandle(Quaternion rotation, Vector3 position, Action <Quaternion> onChanged) { using (EditorGUIEx.ChangeCheck(() => onChanged(rotation))) { rotation = Handles.DoRotationHandle(rotation, position); return(rotation); } }
public override void OnToolGUI(EditorWindow window) { target.bounds = EditorGUIEx.ChangeCheck(() => { Rect bounds = target.bounds; bounds.min = HandlesEx.DoPositionHandle(target.transform, target.bounds.min.xzy(0)).xz(); bounds.max = HandlesEx.DoPositionHandle(target.transform, target.bounds.max.xzy(0)).xz(); return(bounds); }, bounds => { EditorUtility.SetDirty(target); target.OnValidate(); }); }
void OnGUI() { if (settings == null) { UnityEngine.Object[] objectArray = InternalEditorUtility.LoadSerializedFileAndForget(m_SettingsPath); if (objectArray != null && objectArray.Length > 0) { settings = objectArray[0] as UnityExSettings; } if (settings == null) { settings = CreateInstance <UnityExSettings>(); settings.hideFlags = HideFlags.DontSave; settings.name = "UnityEx Settings"; settings.buildName = "Release"; InternalEditorUtility.SaveToSerializedFileAndForget(new UnityEngine.Object[1] { settings }, m_SettingsPath, true); } CheckPaths(); } bool bIsDirty = false; EditorGUILayout.Space(); GUILayout.Label("Project namespace:", EditorStyles.boldLabel); using (EditorGUIEx.ChangeCheck(() => UnityEditorExSettings.instance.Save())) { UnityEditorExSettings.instance.namespaceName = EditorGUILayout.TextField(UnityEditorExSettings.instance.namespaceName); } GUILayout.Label("Project editor source path:", EditorStyles.boldLabel); using (EditorGUIEx.ChangeCheck(() => UnityEditorExSettings.instance.Save())) { UnityEditorExSettings.instance.editorScriptsPath = EditorGUILayout.TextField(UnityEditorExSettings.instance.editorScriptsPath); } GUILayout.Label("UnityEx solution path:", EditorStyles.boldLabel); using (EditorGUIEx.ChangeCheck(() => bIsDirty = true)) { settings.solutionPath = EditorGUILayout.TextField(settings.solutionPath); } if (bIsDirty) { CheckPaths(); } if (EditorGUILayout.DropdownButton(new GUIContent(settings.buildName), FocusType.Keyboard)) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Release"), settings.buildName == "Release", () => { settings.buildName = "Release"; bIsDirty = true; CheckPaths(); }); menu.AddItem(new GUIContent("Debug"), settings.buildName == "Debug", () => { settings.buildName = "Debug"; bIsDirty = true; CheckPaths(); }); menu.DropDown(EditorGUILayoutEx.GetLastRect()); } using (EditorGUIEx.DisabledScopeIf(!m_CanImport)) { if (GUILayout.Button("Import")) { foreach (string file in Directory.GetFiles(m_UnityEngineBuildPath)) { if (file.EndsWith("dll") || file.EndsWith("pdb")) { string fileName = Path.GetFileName(file); string destFile = Path.Combine(m_UnityEngineAssembliesPath, fileName); if (File.GetLastWriteTime(file) != File.GetLastWriteTime(destFile)) { File.Copy(file, destFile, true); EditorProgressBar.ShowProgressBar("Importing {0}...".format(fileName), 1); } } } foreach (string file in Directory.GetFiles(m_UnityEditorBuildPath)) { if (file.EndsWith("dll") || file.EndsWith("pdb")) { string fileName = Path.GetFileName(file); string destFile = Path.Combine(m_UnityEditorAssembliesPath, fileName); if (File.GetLastWriteTime(file) != File.GetLastWriteTime(destFile)) { File.Copy(file, destFile, true); EditorProgressBar.ShowProgressBar("Importing {0}...".format(fileName), 1); } } } EditorProgressBar.ClearProgressBar(); AssetDatabase.Refresh(); } } if (bIsDirty) { InternalEditorUtility.SaveToSerializedFileAndForget(new UnityEngine.Object[1] { settings }, m_SettingsPath, true); } }