/// <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;
	}
	public static void CreatePDGAssetLink()
	{
	    GameObject selectedGO = Selection.activeGameObject;
	    if (selectedGO != null)
	    {
		HEU_HoudiniAssetRoot assetRoot = selectedGO.GetComponent<HEU_HoudiniAssetRoot>();
		if (assetRoot != null)
		{
		    if (assetRoot._houdiniAsset != null)
		    {
			string name = string.Format("{0}_PDGLink", assetRoot._houdiniAsset.AssetName);

			GameObject go = new GameObject(name);
			HEU_PDGAssetLink assetLink = go.AddComponent<HEU_PDGAssetLink>();
			assetLink.Setup(assetRoot._houdiniAsset);

			Selection.activeGameObject = go;
		    }
		    else
		    {
			Debug.LogError("Selected gameobject is not an instantiated HDA. Failed to create PDG Asset Link.");
		    }
		}
		else
		{
		    Debug.LogError("Selected gameobject is not an instantiated HDA. Failed to create PDG Asset Link.");
		}
	    }
	    else
	    {
		//Debug.LogError("Nothing selected. Select an instantiated HDA first.");
		HEU_EditorUtility.DisplayErrorDialog("PDG Asset Link", "No HDA selected. You must select an instantiated HDA first.", "OK");
	    }
	}
Exemple #3
0
	public static void CreateSocketSession()
	{
	    bool bResult = HEU_SessionManager.CreateThriftSocketSession(HEU_PluginSettings.Session_Localhost, HEU_PluginSettings.Session_Port, HEU_PluginSettings.Session_AutoClose, HEU_PluginSettings.Session_Timeout, true);
	    if (!bResult)
	    {
		HEU_EditorUtility.DisplayErrorDialog("Create Session", HEU_SessionManager.GetLastSessionError(), "OK");
	    }
	}
		public static void DebugConnectSocketSession()
		{
			bool bResult = HEU_SessionManager.ConnectThriftSocketSession(HEU_PluginSettings.Session_Localhost, HEU_PluginSettings.Session_Port, HEU_PluginSettings.Session_AutoClose, HEU_PluginSettings.Session_Port);
			if (!bResult)
			{
				HEU_EditorUtility.DisplayErrorDialog("Debug Session", HEU_SessionManager.GetLastSessionError(), "OK");
			}
		}
		public static void DebugConnectPipeSession()
		{
			bool bResult = HEU_SessionManager.ConnectThriftPipeSession(HEU_PluginSettings.Session_PipeName, HEU_PluginSettings.Session_AutoClose, HEU_PluginSettings.Session_Timeout);
			if (!bResult)
			{
				HEU_EditorUtility.DisplayErrorDialog("Debug Session", HEU_SessionManager.GetLastSessionError(), "OK");
			}
		}
Exemple #6
0
	public static void CloseDefaultSession()
	{
	    bool bResult = HEU_SessionManager.CloseDefaultSession();
	    if (!bResult)
	    {
		HEU_EditorUtility.DisplayErrorDialog("Closing Default Session", HEU_SessionManager.GetLastSessionError(), "OK");
	    }
	    else
	    {
		Debug.Log("Houdini Engine Session closed!");
	    }
	}