Manages storage for Houdini Engine plugin data.
Exemplo n.º 1
0
	/// <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;
	}
Exemplo n.º 2
0
		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;
		}
Exemplo n.º 3
0
		/// <summary>
		/// Load stored session data and recreate the session objects.
		/// </summary>
		public static void LoadAllSessionData()
		{
			// Clear existing sessions, and load session data from storage.
			// Then create session for each session data.
			_sessionMap.Clear();

			List<HEU_SessionData> sessionDatas = HEU_PluginStorage.LoadAllSessionData();
			foreach(HEU_SessionData sessionData in sessionDatas)
			{
				if(sessionData != null)
				{
					// Create session based on type
					HEU_SessionBase sessionBase = CreateSessionFromType(sessionData.SessionClassType);
					if (sessionBase != null)
					{
						sessionBase.SetSessionData(sessionData);
						_sessionMap.Add(sessionData.SessionID, sessionBase);

						if(sessionData.IsDefaultSession)
						{
							_defaultSession = sessionBase;
						}

						// Find assets in scene with session ID. Check if valid and reset those that aren't.
						
					}
				}
			}

			InternalValidateSceneAssets();
		}
Exemplo n.º 4
0
		/// <summary>
		/// Load stored session data and recreate the session objects.
		/// </summary>
		public static void LoadAllSessionData()
		{
			// Clear existing sessions, and load session data from storage.
			// Then create session for each session data.
			_sessionMap.Clear();

			List<HEU_SessionData> sessionDatas = HEU_PluginStorage.LoadAllSessionData();
			foreach(HEU_SessionData sessionData in sessionDatas)
			{
				if(sessionData != null)
				{
					// Create session based on type
					HEU_SessionBase sessionBase = CreateSessionFromType(sessionData.SessionClassType);
					if (sessionBase != null)
					{
						sessionBase.SetSessionData(sessionData);
						_sessionMap.Add(sessionData.SessionID, sessionBase);

						if(sessionData.IsDefaultSession)
						{
							_defaultSession = sessionBase;
						}
					}
				}
			}
		}
Exemplo n.º 5
0
	/// <summary>
	/// Tries to load a stored default session. This would be after a code refresh
	/// or if the Houdini session is still running but Unity hasn't connected to it.
	/// </summary>
	/// <returns>True if successfully reconnected to a stored session.</returns>		
	public static bool LoadStoredDefaultSession()
	{
	    // By forcing our plugin and session data to be loaded here, it will
	    // result in all stored sessions to be recreated, including _defaultSession
	    // being initialized if found in storage.
	    HEU_PluginStorage.InstantiateAndLoad();

	    return (_defaultSession != null && _defaultSession.IsSessionValid());
	}
Exemplo n.º 6
0
		/// <summary>
		/// Create new instance if none found.
		/// Loads plugin data from file.
		/// </summary>
		public static void InstantiateAndLoad()
		{
			if (_instance == null)
			{
				_instance = new HEU_PluginStorage();
				_instance.LoadPluginData();

				HEU_SessionManager.LoadAllSessionData();
			}
		}
		/// <summary>
		/// Create new instance if none found.
		/// Loads plugin data from file.
		/// </summary>
		public static void InstantiateAndLoad()
		{
			if (_instance == null)
			{
				_instance = new HEU_PluginStorage();
				_instance.LoadPluginData();

				// Set the current culture based on user plugin setting. By default (fresh install)
				// this sets to InvariantCulture to fix decimal parsing issues on certain locales (like es-ES).
				// Note that this sets for the entire project as long as the plugin is in use.
				// Users can turn this off from Plugin Settings.
				SetCurrentCulture(HEU_PluginSettings.SetCurrentThreadToInvariantCulture);

				HEU_SessionManager.LoadAllSessionData();

				_instance.LoadAssetEnvironmentPaths();
			}
		}
Exemplo n.º 8
0
	/// <summary>
	/// Load stored session data and recreate the session objects.
	/// </summary>
	public static void LoadAllSessionData()
	{
	    // Clear existing sessions, and load session data from storage.
	    // Then create session for each session data.
	    _sessionMap.Clear();

	    List<HEU_SessionData> sessionDatas = HEU_PluginStorage.LoadAllSessionData();
	    foreach (HEU_SessionData sessionData in sessionDatas)
	    {
		if (sessionData != null)
		{
		    try
		    {
			// Create session based on type
			HEU_SessionBase sessionBase = CreateSessionFromType(sessionData.SessionClassType);
			if (sessionBase != null)
			{
			    sessionBase.SetSessionData(sessionData);
			    _sessionMap.Add(sessionData.SessionID, sessionBase);

			    if (sessionData.IsDefaultSession)
			    {
				_defaultSession = sessionBase;
			    }

			    // Find assets in scene with session ID. Check if valid and reset those that aren't.
			}
		    }
		    catch (System.Exception ex)
		    {
			Debug.LogWarningFormat("Loading session with ID {0} failed with {1}. Ignoring the session.", sessionData.SessionID, ex.ToString());
		    }
		}
	    }

	    InternalValidateSceneAssets();
	}
Exemplo n.º 9
0
 private static void EditorQuit()
 {
     Debug.Log("Houdini Engine: Editor is closing. Closing all sessions and clearing cache.");
     HEU_SessionManager.CloseAllSessions();
     HEU_PluginStorage.DeleteAllSavedSessionData();
 }
Exemplo n.º 10
0
	/// <summary>
	/// Save given list of sessions (HEU_SessionData) into storage for retrieval later.
	/// A way to persist current session information through code refresh/compiles.
	/// </summary>
	public static void SaveAllSessionData()
	{
	    List<HEU_SessionBase> sessions = new List<HEU_SessionBase>(_sessionMap.Values);
	    HEU_PluginStorage.SaveAllSessionData(sessions);
	}