/// <summary>
        /// Attempts to connect to running instance of Houdini with SessionSync enabled,
        /// with CONNECTION_ATTEMPT_RATE delay between attempts. Presuming that Houdini was just,
        /// launched this might take a few tries. Times out if unsuccessful after CONNECTION_TIME_OUT
        /// time.
        /// </summary>
        void UpdateConnecting(HEU_SessionSyncData syncData)
        {
            if (syncData == null || syncData.SyncStatus != HEU_SessionSyncData.Status.Connecting)
            {
                return;
            }

            // Attempt connection after waiting for a bit.
            if (Time.realtimeSinceStartup - syncData._timeLastUpdate >= CONNECTION_ATTEMPT_RATE)
            {
                if (InternalConnect(_sessionMode, _pipeName,
                                    HEU_PluginSettings.Session_Localhost, _port,
                                    HEU_PluginSettings.Session_AutoClose,
                                    HEU_PluginSettings.Session_Timeout, false))
                {
                    Log("Initializing...");
                    syncData.SyncStatus = HEU_SessionSyncData.Status.Initializing;

                    try
                    {
                        HEU_SessionManager.InitializeDefaultSession();
                        HEU_SessionManager.GetDefaultSession().GetSessionData().SetSessionSync(syncData);

                        syncData.SyncStatus = HEU_SessionSyncData.Status.Connected;
                        Log("Connected!");
                    }
                    catch (System.Exception ex)
                    {
                        syncData.SyncStatus = HEU_SessionSyncData.Status.Stopped;
                        Log("Connection errored!");
                        Log(ex.ToString());

                        HEU_Logger.Log(ex.ToString());
                    }
                    finally
                    {
                        // Clear this to get out of the connection state
                        _connectionSyncData = null;
                    }
                }
                else if (Time.realtimeSinceStartup - syncData._timeStartConnection >= CONNECTION_TIME_OUT)
                {
                    syncData.SyncStatus = HEU_SessionSyncData.Status.Stopped;
                    Log("Timed out trying to connect to Houdini."
                        + "\nCheck if Houdini is running and SessionSync is enabled."
                        + "\nCheck port or pipe name are correct by comparing with Houdini SessionSync panel.");
                }
                else
                {
                    // Try again in a bit
                    syncData._timeLastUpdate = Time.realtimeSinceStartup;
                }
            }
        }
Exemplo n.º 2
0
	public static void ReconnectToSession()
	{
	    bool bResult = HEU_SessionManager.LoadStoredDefaultSession();
	    if (!bResult)
	    {
		HEU_EditorUtility.DisplayDialog("Reconnecting to Session", HEU_SessionManager.GetLastSessionError(), "OK");
	    }
	    else
	    {
		HEU_Logger.Log("Houdini Engine Session reconnected.");
	    }
	}
Exemplo n.º 3
0
	public static void CloseDefaultSession()
	{
	    bool bResult = HEU_SessionManager.CloseDefaultSession();
	    if (!bResult)
	    {
		HEU_EditorUtility.DisplayErrorDialog("Closing Default Session", HEU_SessionManager.GetLastSessionError(), "OK");
	    }
	    else
	    {
		HEU_Logger.Log("Houdini Engine Session closed!");
	    }
	}
Exemplo n.º 4
0
	public static void PrintDependencies(GameObject targetGO)
	{
#if UNITY_EDITOR
	    HEU_Logger.Log("Print Dependcies: target: " + targetGO.name);
	    UnityEngine.Object[] depends = HEU_EditorUtility.CollectDependencies(targetGO);
	    foreach (UnityEngine.Object obj in depends)
	    {
		HEU_Logger.LogFormat("Dependent: name={0}, type={1}, path={2}, persist={3}, native={4}", obj.name, obj.GetType().ToString(), AssetDatabase.GetAssetOrScenePath(obj), EditorUtility.IsPersistent(obj),
			AssetDatabase.IsNativeAsset(obj));
	    }
#endif
	}
	public bool SaveNodeToFile(string filePath)
	{
	    HEU_SessionBase session = GetHoudiniSession(false);
	    if (session == null)
	    {
		return false;
	    }

	    HEU_Logger.Log("Saving to " + filePath);
	    _nodeSaveFilePath = filePath;

	    return session.SaveNodeToFile(_cookNodeID, filePath);
	}
	/// <summary>
	/// Close all sessions
	/// </summary>
	public static void CloseAllSessions()
	{
	    List<HEU_SessionBase> sessions = new List<HEU_SessionBase>(_sessionMap.Values);
	    foreach (HEU_SessionBase sessionEntry in sessions)
	    {
		if (sessionEntry.GetSessionData() != null)
		{
		    HEU_Logger.Log(HEU_Defines.HEU_NAME + ": Closing session: " + sessionEntry.GetSessionData().SessionID);
		}
		sessionEntry.CloseSession();
	    }
	    _sessionMap.Clear();

	    // Clear out the default session
	    _defaultSession = null;
	}
Exemplo n.º 7
0
	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
	    {
		HEU_Logger.Log("Houdini Engine Session restarted.");
	    }
	}
	/// <summary>
	/// Open given session in a new Houdini instance.
	/// </summary>
	/// <param name="session">Session to open. If null, will use default session.</param>
	/// <returns>True if successfully loaded session</returns>
	public static bool OpenSessionInHoudini(HEU_SessionBase session = null)
	{
	    if (session == null || !session.IsSessionValid())
	    {
		session = GetOrCreateDefaultSession();
		if (session == null || !session.IsSessionValid())
		{
		    session.SetSessionErrorMsg("No valid session found. Unable to open session in Houdini!", true);
		    return false;
		}
	    }

	    string HIPName = string.Format("hscene_{0}.hip", System.IO.Path.GetRandomFileName().Replace(".", ""));
	    string HIPPath = Application.temporaryCachePath + HEU_Platform.DirectorySeparatorStr + HIPName;

	    if (!session.SaveHIPFile(HIPPath, false))
	    {
		session.SetSessionErrorMsg("Unable to save session to .hip file at: " + HIPPath, true);
		return false;
	    }
	    HEU_Logger.Log("Saved session to " + HIPPath);

	    string HoudiniPath = HEU_PluginSettings.HoudiniDebugLaunchPath;

#if UNITY_EDITOR_OSX
	    HoudiniPath = GetHoudiniPathOnMacOS(HoudiniPath);
#endif

	    var HoudiniProcess = new System.Diagnostics.Process();
	    HoudiniProcess.StartInfo.FileName = HoudiniPath;
	    HoudiniProcess.StartInfo.Arguments = string.Format("\"{0}\"", HIPPath);
	    if (!HoudiniProcess.Start())
	    {
		session.SetSessionErrorMsg("Unable to start Houdini. Check that the Houdini Debug Exectable path is valid in Plugin Settings.", true);
		HEU_EditorUtility.RevealInFinder(HIPPath);
		return false;
	    }

	    return true;
	}
Exemplo n.º 9
0
	public static void CloseAllSessions()
	{
	    HEU_SessionManager.CloseAllSessions();
	    HEU_Logger.Log("Houdini Engine Sessions closed!");
	}
 private static void EditorQuit()
 {
     HEU_Logger.Log("Houdini Engine: Editor is closing. Closing all sessions and clearing cache.");
     HEU_SessionManager.CloseAllSessions();
     HEU_PluginStorage.DeleteAllSavedSessionData();
 }