public void OnGUI() { bool guiEnabled = GUI.enabled; _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition); using (var vs = new EditorGUILayout.VerticalScope(GUI.skin.box)) { DrawSection(this, "GENERAL", this.DrawDetailsGeneral, ref _showGeneral); DrawSection(this, "ENVIRONMENT", this.DrawDetailsEnvironment, ref _showEnvironment); DrawSection(this, "COOKING", this.DrawDetailsCooking, ref _showCooking); DrawSection(this, "GEOMETRY", this.DrawDetailsGeometry, ref _showGeometry); DrawSection(this, "SESSION", this.DrawSessionSettings, ref _showSession); DrawSection(this, "TOOLS", this.DrawToolSettings, ref _showTools); DrawSection(this, "ADVANCED", this.DrawAdvancedSettings, ref _showAdvanced); float buttonHeight = 25; float buttonWidth = 200; GUIStyle yellowButtonStyle = new GUIStyle(GUI.skin.button); yellowButtonStyle.normal.textColor = HEU_EditorUI.GetUISafeTextColorYellow(); yellowButtonStyle.fontStyle = FontStyle.Bold; yellowButtonStyle.fontSize = 12; yellowButtonStyle.fixedHeight = buttonHeight; yellowButtonStyle.fixedWidth = buttonWidth; using (var hs = new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button(HEU_EditorStrings.RELOAD_SETTINGS, yellowButtonStyle)) { if (HEU_EditorUtility.DisplayDialog(HEU_EditorStrings.REVERT_SETTINGS + "?", "Are you sure you want to reload plugin settings from heu_settings.ini file?", "Yes", "No")) { HEU_PluginStorage.LoadFromSavedFile(); ResetStateAndRepaint(); } } GUILayout.Space(10); if (GUILayout.Button(HEU_EditorStrings.REVERT_SETTINGS, yellowButtonStyle)) { if (HEU_EditorUtility.DisplayDialog(HEU_EditorStrings.REVERT_SETTINGS + "?", "Are you sure you want to revert all " + HEU_Defines.HEU_PRODUCT_NAME + " plugin settings?", "Yes", "No")) { HEU_PluginStorage.ClearPluginData(); ResetStateAndRepaint(); } } GUILayout.FlexibleSpace(); } } EditorGUILayout.EndScrollView(); GUI.enabled = guiEnabled; }
/// <summary> /// Returns a valid session by either reconnecting to an existing session, or creating a new session. /// Note that this will display error (once) if unable to get a valid session. /// </summary> /// <returns>A session object (new or existing). Session might not actually have connected successfully. Check IsSessionValid() and error message./returns> public static HEU_SessionBase GetOrCreateDefaultSession(bool bNotifyUserError = true) { if (_defaultSession == null) { // After a code refresh, _defaultSession might be null. So try loading stored plugin data to see if we can get it back. HEU_PluginStorage.InstantiateAndLoad(); } if (_defaultSession != null && _defaultSession.IsSessionValid()) { return _defaultSession; } else if (_defaultSession == null || _defaultSession.ConnectionState == SessionConnectionState.NOT_CONNECTED) { // Try creating it if we haven't tried yet bNotifyUserError &= !CreateThriftPipeSession(HEU_PluginSettings.Session_PipeName, HEU_PluginSettings.Session_AutoClose, HEU_PluginSettings.Session_Timeout, bNotifyUserError); } if (bNotifyUserError && !_defaultSession.UserNotifiedSessionInvalid) { _defaultSession.UserNotifiedSessionInvalid = true; HEU_EditorUtility.DisplayErrorDialog(HEU_Defines.HEU_ERROR_TITLE, HEU_SessionManager.GetLastSessionError(), "OK"); HEU_EditorUtility.DisplayDialog(HEU_Defines.HEU_INSTALL_INFO, HEU_HAPIUtility.GetHoudiniEngineInstallationInfo(), "OK"); } return _defaultSession; }
/// <summary> /// Return the saved Houdini install path. /// Checks if the plugin has been updated, and if so, asks /// user whether they want to switch to new version. /// If user switches, then this returns null to allow installed version /// to be used. /// </summary> /// <returns>The saved Houdini install path or null if it doesn't /// exist or user wants to use installed version</returns> public static string GetSavedHoudiniPath() { string HAPIPath = HEU_PluginSettings.HoudiniInstallPath; if (!string.IsNullOrEmpty(HAPIPath)) { // First check if the last stored installed Houdini version matches current installed version string lastHoudiniVersion = HEU_PluginSettings.LastHoudiniVersion; if (!string.IsNullOrEmpty(lastHoudiniVersion)) { if (!lastHoudiniVersion.Equals(HEU_HoudiniVersion.HOUDINI_VERSION_STRING)) { // Mismatch means different version of the plugin has been installed. // Ask user if they want to update their HAPIPath. // Confirmation means to clear out the saved HAPI path and use // the default one specified by the plugin. string title = "Updated Houdini Engine Plugin Detected"; string msg = string.Format("You have overriden the plugin's default Houdini version with your own, but the plugin has been updated.\n" + "Would you like to use the updated plugin's default Houdini version?."); if (HEU_EditorUtility.DisplayDialog(title, msg, "Yes", "No")) { HEU_PluginSettings.HoudiniInstallPath = ""; HAPIPath = null; } // Always update LastHoudiniVersion so this doesn't keep asking HEU_PluginSettings.LastHoudiniVersion = HEU_HoudiniVersion.HOUDINI_VERSION_STRING; } } } return HAPIPath; }
/// <summary> /// Callback when new prefab instances gets created or updated in Unity scene. /// The plugin does not support creating prefab of HDAs directly /// so this notifies user and provides a way to clean up the created prefab. /// </summary> /// <param name="instance">New prefab instance that was created</param> static void OnPrefabInstanceUpdate(GameObject instance) { #if UNITY_EDITOR && HOUDINIENGINEUNITY_ENABLED && UNITY_2017_1_OR_NEWER var heu_root = instance.GetComponent<HEU_HoudiniAssetRoot>(); if (heu_root != null && heu_root._houdiniAsset != null && (HEU_EditorUtility.IsPrefabInstance(instance) || HEU_EditorUtility.IsPrefabAsset(instance)) && !heu_root._houdiniAsset.WarnedPrefabNotSupported) { string prefabPath = HEU_EditorUtility.GetPrefabAssetPath(instance); string title = HEU_Defines.HEU_PRODUCT_NAME + " Prefabs Not Supported"; string message = "Creating prefab of an HDA is not supported by HoudniEngine.\n\n" + "It is recommended to select 'Remove Prefab' to destroy new prefab " + "and revert to original asset.\n\n" + "Prefab: " + prefabPath; heu_root._houdiniAsset.WarnedPrefabNotSupported = true; if (HEU_EditorUtility.DisplayDialog(title, message, "Remove Prefab & Revert", "Keep Prefab")) { HEU_EditorUtility.DisconnectPrefabInstance(instance); HEU_AssetDatabase.DeleteAssetAtPath(prefabPath); } } #endif }
public static void SaveSessionToHIP() { bool bResult = HEU_SessionManager.SaveSessionToHIP(false); if (!bResult) { HEU_EditorUtility.DisplayDialog("Saving Session to HIP", HEU_SessionManager.GetLastSessionError(), "OK"); } }
public static void OpenSceneHoudini() { bool bResult = HEU_SessionManager.OpenSessionInHoudini(); if (!bResult) { HEU_EditorUtility.DisplayDialog("Opening Session in Houdini", HEU_SessionManager.GetLastSessionError(), "OK"); } }
public static void ReconnectToSession() { bool bResult = HEU_SessionManager.LoadStoredDefaultSession(); if (!bResult) { HEU_EditorUtility.DisplayDialog("Reconnecting to Session", HEU_SessionManager.GetLastSessionError(), "OK"); } else { Debug.Log("Houdini Engine Session reconnected."); } }
public static void ReinitializeSession() { bool bResult = HEU_SessionManager.RestartSession(); if(!bResult) { HEU_EditorUtility.DisplayDialog("Reinitializing Session", HEU_SessionManager.GetLastSessionError(), "OK"); } else { Debug.Log("Houdini Engine Session restarted."); } }
public static bool CreateAndCookAssetNode(HEU_SessionBase session, string assetName, bool bCookTemplatedGeos, out HAPI_NodeId newAssetID) { newAssetID = HEU_Defines.HEU_INVALID_NODE_ID; // Create top level node. Note that CreateNode will cook the node if HAPI was initialized with threaded cook setting on. bool bResult = session.CreateNode(-1, assetName, "", false, out newAssetID); if (!bResult) { return(false); } // Make sure cooking is successfull before proceeding. Any licensing or file data issues will be caught here. if (!ProcessHoudiniCookStatus(session, assetName)) { return(false); } // In case the cooking wasn't done previously, force it now. bResult = CookNodeInHoudini(session, newAssetID, bCookTemplatedGeos, assetName); if (!bResult) { // When cook failed, deleted the node created earlier session.DeleteNode(newAssetID); newAssetID = HEU_Defines.HEU_INVALID_NODE_ID; return(false); } // Get the asset ID HAPI_AssetInfo assetInfo = new HAPI_AssetInfo(); bResult = session.GetAssetInfo(newAssetID, ref assetInfo); if (bResult) { // Check for any errors HAPI_ErrorCodeBits errors = session.CheckForSpecificErrors(newAssetID, (HAPI_ErrorCodeBits)HAPI_ErrorCode.HAPI_ERRORCODE_ASSET_DEF_NOT_FOUND); if (errors > 0) { // TODO: revisit for UI improvement HEU_EditorUtility.DisplayDialog("Asset Missing Sub-asset Definitions", "There are undefined nodes. This is due to not being able to find specific " + "asset definitions.", "Ok"); return(false); } } return(true); }
public static void ReinitializeSession() { // Force to find engine path again if not found. if (!HEU_Platform.IsPathSet) { HEU_Platform.SetHoudiniEnginePath(); } bool bResult = HEU_SessionManager.RestartSession(); if (!bResult) { HEU_EditorUtility.DisplayDialog("Reinitializing Session", HEU_SessionManager.GetLastSessionError(), "OK"); } else { Debug.Log("Houdini Engine Session restarted."); } }
/// <summary> /// Draw the Generate section. /// </summary> private static bool DrawGenerateSection(HEU_HoudiniAssetRoot assetRoot, SerializedObject assetRootSerializedObject, HEU_HoudiniAsset asset, SerializedObject assetObject) { bool bSkipDrawing = false; float separatorDistance = 5f; float screenWidth = EditorGUIUtility.currentViewWidth; float buttonHeight = 30f; float widthPadding = 55f; float doubleButtonWidth = Mathf.Round(screenWidth - widthPadding + separatorDistance); float singleButtonWidth = Mathf.Round((screenWidth - widthPadding) * 0.5f); GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.fontStyle = FontStyle.Bold; buttonStyle.fontSize = 11; buttonStyle.alignment = TextAnchor.MiddleLeft; buttonStyle.fixedHeight = buttonHeight; buttonStyle.padding.left = 6; buttonStyle.padding.right = 6; buttonStyle.margin.left = 0; buttonStyle.margin.right = 0; GUIStyle centredButtonStyle = new GUIStyle(buttonStyle); centredButtonStyle.alignment = TextAnchor.MiddleCenter; GUIStyle buttonSetStyle = new GUIStyle(GUI.skin.box); RectOffset br = buttonSetStyle.margin; br.left = 4; br.right = 4; buttonSetStyle.margin = br; GUIStyle boxStyle = new GUIStyle(GUI.skin.GetStyle("ColorPickerBackground")); br = boxStyle.margin; br.left = 4; br.right = 4; boxStyle.margin = br; boxStyle.padding = br; GUIStyle promptButtonStyle = new GUIStyle(GUI.skin.button); promptButtonStyle.fontSize = 11; promptButtonStyle.alignment = TextAnchor.MiddleCenter; promptButtonStyle.fixedHeight = 30; promptButtonStyle.margin.left = 34; promptButtonStyle.margin.right = 34; _recookhdaContent.text = " Recook Asset"; HEU_HoudiniAsset.AssetBuildAction pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.NONE; SerializedProperty pendingBuildProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_requestBuildAction"); if (pendingBuildProperty != null) { pendingBuildAction = (HEU_HoudiniAsset.AssetBuildAction)pendingBuildProperty.enumValueIndex; } // Track changes for the build and bake targets EditorGUI.BeginChangeCheck(); HEU_HoudiniAsset.AssetCookStatus cookStatus = GetCookStatusFromSerializedAsset(assetObject); if (cookStatus == HEU_HoudiniAsset.AssetCookStatus.SELECT_SUBASSET) { // Prompt user to select subasset GUIStyle promptStyle = new GUIStyle(GUI.skin.label); promptStyle.fontStyle = FontStyle.Bold; promptStyle.normal.textColor = HEU_EditorUI.IsEditorDarkSkin() ? Color.green : Color.blue; EditorGUILayout.LabelField("SELECT AN ASSET TO INSTANTIATE:", promptStyle); EditorGUILayout.Separator(); int selectedIndex = -1; string[] subassetNames = asset.SubassetNames; for (int i = 0; i < subassetNames.Length; ++i) { if (GUILayout.Button(subassetNames[i], promptButtonStyle)) { selectedIndex = i; break; } EditorGUILayout.Separator(); } if (selectedIndex >= 0) { SerializedProperty selectedIndexProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_selectedSubassetIndex"); if (selectedIndexProperty != null) { selectedIndexProperty.intValue = selectedIndex; } } bSkipDrawing = true; } else { HEU_EditorUI.BeginSection(); { if (cookStatus == HEU_HoudiniAsset.AssetCookStatus.COOKING || cookStatus == HEU_HoudiniAsset.AssetCookStatus.POSTCOOK) { _recookhdaContent.text = " Cooking Asset"; } else if (cookStatus == HEU_HoudiniAsset.AssetCookStatus.LOADING || cookStatus == HEU_HoudiniAsset.AssetCookStatus.POSTLOAD) { _reloadhdaContent.text = " Loading Asset"; } SerializedProperty showGenerateProperty = assetObject.FindProperty("_showGenerateSection"); showGenerateProperty.boolValue = HEU_EditorUI.DrawFoldOut(showGenerateProperty.boolValue, "GENERATE"); if (showGenerateProperty.boolValue) { //bool bHasPendingAction = (pendingBuildAction != HEU_HoudiniAsset.AssetBuildAction.NONE) || (cookStatus != HEU_HoudiniAsset.AssetCookStatus.NONE); HEU_EditorUI.DrawSeparator(); //EditorGUI.BeginDisabledGroup(bHasPendingAction); using (var hs = new EditorGUILayout.HorizontalScope(boxStyle)) { if (GUILayout.Button(_reloadhdaContent, buttonStyle, GUILayout.Width(singleButtonWidth))) { pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.RELOAD; bSkipDrawing = true; } GUILayout.Space(separatorDistance); if (!bSkipDrawing && GUILayout.Button(_recookhdaContent, buttonStyle, GUILayout.Width(singleButtonWidth))) { pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.COOK; bSkipDrawing = true; } } using (var hs = new EditorGUILayout.HorizontalScope(boxStyle)) { float tripleButtonWidth = Mathf.Round((screenWidth - widthPadding) * 0.33f); if (GUILayout.Button(_removeheContent, buttonStyle, GUILayout.Width(tripleButtonWidth))) { pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.STRIP_HEDATA; bSkipDrawing = true; } GUILayout.Space(separatorDistance); if (GUILayout.Button(_duplicateContent, buttonStyle, GUILayout.Width(tripleButtonWidth))) { pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.DUPLICATE; bSkipDrawing = true; } GUILayout.Space(separatorDistance); if (GUILayout.Button(_resetParamContent, buttonStyle, GUILayout.Width(tripleButtonWidth))) { pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.RESET_PARAMS; bSkipDrawing = true; } } //EditorGUI.EndDisabledGroup(); HEU_EditorUI.DrawSeparator(); } } HEU_EditorUI.EndSection(); HEU_EditorUI.DrawSeparator(); HEU_EditorUI.BeginSection(); { SerializedProperty showBakeProperty = assetObject.FindProperty("_showBakeSection"); showBakeProperty.boolValue = HEU_EditorUI.DrawFoldOut(showBakeProperty.boolValue, "BAKE"); if (showBakeProperty.boolValue) { if (!bSkipDrawing) { // Bake -> New Instance, New Prefab, Existing instance or prefab using (var vs = new EditorGUILayout.HorizontalScope(boxStyle)) { if (GUILayout.Button(_bakegameobjectContent, buttonStyle, GUILayout.Width(singleButtonWidth))) { asset.BakeToNewStandalone(); } GUILayout.Space(separatorDistance); if (GUILayout.Button(_bakeprefabContent, buttonStyle, GUILayout.Width(singleButtonWidth))) { asset.BakeToNewPrefab(); } } HEU_EditorUI.DrawSeparator(); using (var hs2 = new EditorGUILayout.VerticalScope(boxStyle)) { if (GUILayout.Button(_bakeandreplaceContent, centredButtonStyle, GUILayout.Width(doubleButtonWidth))) { if (assetRoot._bakeTargets == null || assetRoot._bakeTargets.Count == 0) { // No bake target means user probably forgot to set one. So complain! HEU_EditorUtility.DisplayDialog("No Bake Targets", "Bake Update requires atleast one valid GameObject.\n\nDrag a GameObject or Prefab onto the Drag and drop GameObjects / Prefabs field!", "OK"); } else { int numTargets = assetRoot._bakeTargets.Count; for (int i = 0; i < numTargets; ++i) { GameObject bakeGO = assetRoot._bakeTargets[i]; if (bakeGO != null) { if (HEU_EditorUtility.IsPrefabAsset(bakeGO)) { // Prefab asset means its the source prefab, and not an instance of it asset.BakeToExistingPrefab(bakeGO); } else { // This is for all standalone (including prefab instances) asset.BakeToExistingStandalone(bakeGO); } } else { Debug.LogWarning("Unable to bake to null target at index " + i); } } } } using (var hs = new EditorGUILayout.VerticalScope(buttonSetStyle)) { SerializedProperty bakeTargetsProp = assetRootSerializedObject.FindProperty("_bakeTargets"); if (bakeTargetsProp != null) { EditorGUILayout.PropertyField(bakeTargetsProp, _dragAndDropField, true, GUILayout.Width(doubleButtonWidth - 9f)); } } } } } } HEU_EditorUI.EndSection(); HEU_EditorUI.DrawSeparator(); if (pendingBuildAction != HEU_HoudiniAsset.AssetBuildAction.NONE) { // Sanity check to make sure the asset is part of the AssetUpater HEU_AssetUpdater.AddAssetForUpdate(asset); // Apply pending build action based on user UI interaction above pendingBuildProperty.enumValueIndex = (int)pendingBuildAction; if (pendingBuildAction == HEU_HoudiniAsset.AssetBuildAction.COOK) { // Recook should only update parameters that haven't changed. Otherwise if not checking and updating parameters, // then buttons will trigger callbacks on Recook which is not desired. SerializedProperty checkParameterChange = HEU_EditorUtility.GetSerializedProperty(assetObject, "_checkParameterChangeForCook"); if (checkParameterChange != null) { checkParameterChange.boolValue = true; } } } } if (EditorGUI.EndChangeCheck()) { assetRootSerializedObject.ApplyModifiedProperties(); assetObject.ApplyModifiedProperties(); } return bSkipDrawing; }
public static void ShowInstallationInfo() { HEU_EditorUtility.DisplayDialog(HEU_Defines.HEU_INSTALL_INFO, HEU_HAPIUtility.GetHoudiniEngineInstallationInfo(), "OK"); }
public static void GetSessionInfo() { HEU_EditorUtility.DisplayDialog("Houdini Engine", HEU_SessionManager.GetSessionInfo(), "OK"); }
private bool DrawDetailsGeneral() { bool bChanged = false; { string oldPath = HEU_PluginSettings.AssetCachePath; EditorGUILayout.LabelField(new GUIContent("Houdini Asset Cache Path:", "Files generated by this plugin will be stored in this folder path relative to Assets/.")); string newPath = EditorGUILayout.TextField("", oldPath); if (!newPath.Equals(oldPath)) { HEU_PluginSettings.AssetCachePath = newPath; bChanged = true; } } HEU_EditorUI.DrawSeparator(); { string oldPath = HEU_PluginSettings.HoudiniInstallPath; string fileExt = ""; EditorGUILayout.LabelField(new GUIContent("Override Houdini Install Path:", "Set a specific Houdini installation to use for this plugin. The plugin's default version of Houdini will be ignored.")); using (new EditorGUILayout.HorizontalScope()) { string newPath = EditorGUILayout.DelayedTextField(oldPath); GUIStyle buttonStyle = HEU_EditorUI.GetNewButtonStyle_MarginPadding(0, 0); if (GUILayout.Button("...", buttonStyle, GUILayout.Width(30), GUILayout.Height(18))) { string panelMsg = "Select Houdini Install Path"; #if UNITY_EDITOR_OSX panelMsg += " (.app)"; #endif string openFilePath = UnityEditor.EditorUtility.OpenFolderPanel(panelMsg, newPath, fileExt); if (!string.IsNullOrEmpty(openFilePath)) { newPath = openFilePath; } } if (!newPath.Equals(oldPath)) { string msgPath = !string.IsNullOrEmpty(newPath) ? newPath : HEU_Platform.GetHoudiniEngineDefaultPath(); string confirmMsg = string.Format( "Change the Houdini install path?\n" + " New path: {0}\n\n" + "You will need to restart Unity to use this path!", msgPath); bool result = HEU_EditorUtility.DisplayDialog("Houdini Install Path Changed", confirmMsg, "Confirm", "Cancel"); if (result) { HEU_PluginSettings.HoudiniInstallPath = newPath; bChanged = true; } } } #if UNITY_EDITOR_OSX GUIStyle labelStyle = new GUIStyle(GUI.skin.label); labelStyle.wordWrap = true; EditorGUILayout.LabelField(" On macOS, you'll need to select the path to the .app folder.\n E.g. /Applications/Houdini/Houdini16.5.616/Houdini Core 16.5.616.app", labelStyle); #endif } HEU_EditorUI.DrawSeparator(); { string oldPath = HEU_PluginSettings.HoudiniDebugLaunchPath; string fileExt = ""; EditorGUILayout.LabelField(new GUIContent("Houdini Debug Executable:", "Set Houdini executable to launch when opening debug scenes.")); using (new EditorGUILayout.HorizontalScope()) { string newPath = EditorGUILayout.DelayedTextField(oldPath); GUIStyle buttonStyle = HEU_EditorUI.GetNewButtonStyle_MarginPadding(0, 0); if (GUILayout.Button("...", buttonStyle, GUILayout.Width(30), GUILayout.Height(18))) { string panelMsg = "Select Houdini Executable"; #if UNITY_EDITOR_OSX panelMsg += " (.app)"; #endif string openFilePath = UnityEditor.EditorUtility.OpenFilePanel(panelMsg, newPath, fileExt); if (!string.IsNullOrEmpty(openFilePath)) { newPath = openFilePath; } } if (!newPath.Equals(oldPath)) { HEU_PluginSettings.HoudiniDebugLaunchPath = newPath; bChanged = true; } } #if UNITY_EDITOR_OSX GUIStyle labelStyle = new GUIStyle(GUI.skin.label); labelStyle.wordWrap = true; EditorGUILayout.LabelField(" On macOS, you'll need to select the path to the .app folder.\n E.g. /Applications/Houdini/Houdini16.5.616/Houdini Core 16.5.616.app", labelStyle); #endif } HEU_EditorUI.DrawSeparator(); { bool oldValue = HEU_PluginSettings.UseFullPathNamesForOutput; bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Use Full Path Names For Output"); if (!newValue.Equals(oldValue)) { HEU_PluginSettings.UseFullPathNamesForOutput = newValue; bChanged = true; } } HEU_EditorUI.DrawSeparator(); { bool oldValue = HEU_PluginSettings.SetCurrentThreadToInvariantCulture; bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Set Current Thread To Invariant Culture", "Enabling this sets to use InvariantCutulre which fixes locale-specific parsing issues such as using comma instead of dot for decimals."); if (!newValue.Equals(oldValue)) { HEU_PluginSettings.SetCurrentThreadToInvariantCulture = newValue; bChanged = true; } } return bChanged; }
private static bool DrawBakeSection(HEU_HoudiniAssetRoot assetRoot, SerializedObject assetRootSerializedObject, HEU_HoudiniAsset asset, SerializedObject assetObject, ref HEU_HoudiniAsset.AssetBuildAction pendingBuildAction) { bool bSkipAutoCook = false; HEU_EditorUI.BeginSection(); { SerializedProperty showBakeProperty = assetObject.FindProperty("_showBakeSection"); showBakeProperty.boolValue = HEU_EditorUI.DrawFoldOut(showBakeProperty.boolValue, "BAKE"); if (showBakeProperty.boolValue) { // Bake -> New Instance, New Prefab, Existing instance or prefab using (var hs = new EditorGUILayout.HorizontalScope(_mainBoxStyle)) { if (GUILayout.Button(_bakegameobjectContent, _mainButtonStyle)) { asset.BakeToNewStandalone(); } GUILayout.Space(_mainButtonSeparatorDistance); if (GUILayout.Button(_bakeprefabContent, _mainButtonStyle)) { asset.BakeToNewPrefab(); } } using (var vs = new EditorGUILayout.VerticalScope(_mainBoxStyle)) { if (GUILayout.Button(_removeheContent, _mainButtonStyle)) { pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.STRIP_HEDATA; bSkipAutoCook = true; } } using (var hs2 = new EditorGUILayout.VerticalScope(_mainBoxStyle)) { if (GUILayout.Button(_bakeandreplaceContent, _mainCentredButtonStyle)) { if (assetRoot._bakeTargets == null || assetRoot._bakeTargets.Count == 0) { // No bake target means user probably forgot to set one. So complain! HEU_EditorUtility.DisplayDialog("No Bake Targets", "Bake Update requires atleast one valid GameObject.\n\nDrag a GameObject or Prefab onto the Drag and drop GameObjects / Prefabs field!", "OK"); } else { int numTargets = assetRoot._bakeTargets.Count; for (int i = 0; i < numTargets; ++i) { GameObject bakeGO = assetRoot._bakeTargets[i]; if (bakeGO != null) { if (HEU_EditorUtility.IsPrefabAsset(bakeGO)) { // Prefab asset means its the source prefab, and not an instance of it asset.BakeToExistingPrefab(bakeGO); } else { // This is for all standalone (including prefab instances) asset.BakeToExistingStandalone(bakeGO); } } else { Debug.LogWarning("Unable to bake to null target at index " + i); } } } } using (var hs = new EditorGUILayout.VerticalScope(_mainButtonSetStyle)) { SerializedProperty bakeTargetsProp = assetRootSerializedObject.FindProperty("_bakeTargets"); if (bakeTargetsProp != null) { EditorGUILayout.PropertyField(bakeTargetsProp, _dragAndDropField, true); } } } } } HEU_EditorUI.EndSection(); HEU_EditorUI.DrawSeparator(); return bSkipAutoCook; }
/// <summary> /// Draw the Generate section. /// </summary> private static bool DrawGenerateSection(HEU_HoudiniAssetRoot assetRoot, SerializedObject assetRootSerializedObject, HEU_HoudiniAsset asset, SerializedObject assetObject) { bool bSkipDrawing = false; float separatorDistance = 5f; float screenWidth = EditorGUIUtility.currentViewWidth; float buttonHeight = 30f; float widthPadding = 55f; float doubleButtonWidth = Mathf.Round(screenWidth - widthPadding + separatorDistance); float singleButtonWidth = Mathf.Round((screenWidth - widthPadding) * 0.5f); Texture2D reloadhdaIcon = Resources.Load("heu_reloadhdaIcon") as Texture2D; Texture2D recookhdaIcon = Resources.Load("heu_recookhdaIcon") as Texture2D; Texture2D bakegameobjectIcon = Resources.Load("heu_bakegameobjectIcon") as Texture2D; Texture2D bakeprefabIcon = Resources.Load("heu_bakeprefabIcon") as Texture2D; Texture2D bakeandreplaceIcon = Resources.Load("heu_bakeandreplaceIcon") as Texture2D; Texture2D removeheIcon = Resources.Load("heu_removeheIcon") as Texture2D; Texture2D duplicateAssetIcon = Resources.Load("heu_duplicateassetIcon") as Texture2D; GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.fontStyle = FontStyle.Bold; buttonStyle.fontSize = 11; buttonStyle.alignment = TextAnchor.MiddleLeft; buttonStyle.fixedHeight = buttonHeight; buttonStyle.padding.left = 6; buttonStyle.padding.right = 6; buttonStyle.margin.left = 0; buttonStyle.margin.right = 0; GUIStyle centredButtonStyle = new GUIStyle(buttonStyle); centredButtonStyle.alignment = TextAnchor.MiddleCenter; GUIStyle buttonSetStyle = new GUIStyle(GUI.skin.box); RectOffset br = buttonSetStyle.margin; br.left = 4; br.right = 4; buttonSetStyle.margin = br; GUIStyle boxStyle = new GUIStyle(GUI.skin.GetStyle("ColorPickerBackground")); br = boxStyle.margin; br.left = 4; br.right = 4; boxStyle.margin = br; boxStyle.padding = br; GUIContent reloadhdaContent = new GUIContent(" Reload Asset", reloadhdaIcon); GUIContent recookhdaContent = new GUIContent(" Recook Asset", recookhdaIcon); GUIContent bakegameobjectContent = new GUIContent(" Bake GameObject", bakegameobjectIcon); GUIContent bakeprefabContent = new GUIContent(" Bake Prefab", bakeprefabIcon); GUIContent bakeandreplaceContent = new GUIContent(" Bake Update", bakeandreplaceIcon); GUIContent removeheContent = new GUIContent(" Keep Only Output", removeheIcon); GUIContent duplicateContent = new GUIContent(" Duplicate Asset", duplicateAssetIcon); HEU_HoudiniAsset.AssetBuildAction pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.NONE; SerializedProperty pendingBuildProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_requestBuildAction"); if (pendingBuildProperty != null) { pendingBuildAction = (HEU_HoudiniAsset.AssetBuildAction)pendingBuildProperty.enumValueIndex; } // Track changes for the build and bake targets EditorGUI.BeginChangeCheck(); HEU_EditorUI.BeginSection(); { HEU_HoudiniAsset.AssetCookStatus cookStatus = HEU_HoudiniAsset.AssetCookStatus.NONE; SerializedProperty cookStatusProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_cookStatus"); if (cookStatusProperty != null) { cookStatus = (HEU_HoudiniAsset.AssetCookStatus)cookStatusProperty.enumValueIndex; if(cookStatus == HEU_HoudiniAsset.AssetCookStatus.COOKING || cookStatus == HEU_HoudiniAsset.AssetCookStatus.POSTCOOK) { recookhdaContent.text = " Cooking Asset"; } else if (cookStatus == HEU_HoudiniAsset.AssetCookStatus.LOADING || cookStatus == HEU_HoudiniAsset.AssetCookStatus.POSTLOAD) { reloadhdaContent.text = " Loading Asset"; } } SerializedProperty showGenerateProperty = assetObject.FindProperty("_showGenerateSection"); showGenerateProperty.boolValue = HEU_EditorUI.DrawFoldOut(showGenerateProperty.boolValue, "GENERATE"); if (showGenerateProperty.boolValue) { bool bHasPendingAction = (pendingBuildAction != HEU_HoudiniAsset.AssetBuildAction.NONE) || (cookStatus != HEU_HoudiniAsset.AssetCookStatus.NONE); HEU_EditorUI.DrawSeparator(); EditorGUI.BeginDisabledGroup(bHasPendingAction); using (var hs = new EditorGUILayout.HorizontalScope(boxStyle)) { if (GUILayout.Button(reloadhdaContent, buttonStyle, GUILayout.Width(singleButtonWidth))) { pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.RELOAD; bSkipDrawing = true; } GUILayout.Space(separatorDistance); if (!bSkipDrawing && GUILayout.Button(recookhdaContent, buttonStyle, GUILayout.Width(singleButtonWidth))) { pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.COOK; bSkipDrawing = true; } } using (var hs = new EditorGUILayout.HorizontalScope(boxStyle)) { if (GUILayout.Button(removeheContent, buttonStyle, GUILayout.Width(singleButtonWidth))) { pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.STRIP_HEDATA; bSkipDrawing = true; } GUILayout.Space(separatorDistance); if (GUILayout.Button(duplicateContent, buttonStyle, GUILayout.Width(singleButtonWidth))) { pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.DUPLICATE; bSkipDrawing = true; } } EditorGUI.EndDisabledGroup(); HEU_EditorUI.DrawSeparator(); } } HEU_EditorUI.EndSection(); HEU_EditorUI.DrawSeparator(); HEU_EditorUI.BeginSection(); { SerializedProperty showBakeProperty = assetObject.FindProperty("_showBakeSection"); showBakeProperty.boolValue = HEU_EditorUI.DrawFoldOut(showBakeProperty.boolValue, "BAKE"); if (showBakeProperty.boolValue) { if (!bSkipDrawing) { // Bake -> New Instance, New Prefab, Existing instance or prefab using (var vs = new EditorGUILayout.HorizontalScope(boxStyle)) { if (GUILayout.Button(bakegameobjectContent, buttonStyle, GUILayout.Width(singleButtonWidth))) { asset.BakeToNewStandalone(); } GUILayout.Space(separatorDistance); if (GUILayout.Button(bakeprefabContent, buttonStyle, GUILayout.Width(singleButtonWidth))) { asset.BakeToNewPrefab(); } } HEU_EditorUI.DrawSeparator(); using (var hs2 = new EditorGUILayout.VerticalScope(boxStyle)) { if (GUILayout.Button(bakeandreplaceContent, centredButtonStyle, GUILayout.Width(doubleButtonWidth))) { if (assetRoot._bakeTargets == null || assetRoot._bakeTargets.Count == 0) { // No bake target means user probably forgot to set one. So complain! HEU_EditorUtility.DisplayDialog("No Bake Targets", "Bake Update requires atleast one valid GameObject.\n\nDrag a GameObject or Prefab onto the Drag and drop GameObjects / Prefabs field!", "OK"); } else { int numTargets = assetRoot._bakeTargets.Count; for(int i = 0; i < numTargets; ++i) { GameObject bakeGO = assetRoot._bakeTargets[i]; if (bakeGO != null) { if (HEU_EditorUtility.IsPrefabOriginal(bakeGO)) { // Prefab original means its true prefab, and not an instance of it // TODO: allow user to cancel asset.BakeToExistingPrefab(bakeGO); } else { // This is for all standalone (including prefab instances) asset.BakeToExistingStandalone(bakeGO); } } else { Debug.LogWarning("Unable to bake to null target at index " + i); } } } } using (var hs = new EditorGUILayout.VerticalScope(buttonSetStyle)) { SerializedProperty bakeTargetsProp = assetRootSerializedObject.FindProperty("_bakeTargets"); if (bakeTargetsProp != null) { EditorGUILayout.PropertyField(bakeTargetsProp, new GUIContent("Drag & drop GameObjects / Prefabs:"), true, GUILayout.Width(doubleButtonWidth - 9f)); } } } } } } HEU_EditorUI.EndSection(); HEU_EditorUI.DrawSeparator(); if(pendingBuildAction != HEU_HoudiniAsset.AssetBuildAction.NONE) { // Sanity check to make sure the asset is part of the AssetUpater HEU_AssetUpdater.AddAssetForUpdate(asset); // Apply pending build action based on user UI interaction above pendingBuildProperty.enumValueIndex = (int)pendingBuildAction; if (pendingBuildAction == HEU_HoudiniAsset.AssetBuildAction.COOK) { // Forcing recook without checking for changes allows users to do a semi-reset on the output, // without needing to reload (loose changes) or change parameter then undo. SerializedProperty checkParameterChange = HEU_EditorUtility.GetSerializedProperty(assetObject, "_checkParameterChangeForCook"); if (checkParameterChange != null) { checkParameterChange.boolValue = false; } } } if (EditorGUI.EndChangeCheck()) { assetRootSerializedObject.ApplyModifiedProperties(); assetObject.ApplyModifiedProperties(); } return bSkipDrawing; }