Ejemplo n.º 1
0
        /// <summary>
        /// Returns the application path of the specified application, as found in the system registry.
        /// </summary>
        /// <param name="appName">Name of the application as set in the registry.</param>
        /// <returns>Returns application path of the specified applicatoin.</returns>
        public static string GetApplicationPath(string appName)
        {
            // For Windows, we look at the registry entries made by the Houdini installer. We look for the
            // "active version" key which gives us the most recently installed Houdini version. Using the
            // active version we find the registry made by that particular installer and find the install
            // path.

            string correctVersion =
                HEU_HoudiniVersion.HOUDINI_MAJOR + "." +
                HEU_HoudiniVersion.HOUDINI_MINOR + "." +
                HEU_HoudiniVersion.HOUDINI_BUILD;

            // Note the extra 0 for the "minor-minor" version that's needed here.
            string correctVersionKey =
                HEU_HoudiniVersion.HOUDINI_MAJOR + "." +
                HEU_HoudiniVersion.HOUDINI_MINOR + "." +
                "0" + "." +
                HEU_HoudiniVersion.HOUDINI_BUILD;

            // HOUDINI_PATCH is a const variable, hence the 'unreachable code' warning.
            // However, it's a const variable in HoudiniVersion.cs which is a generated
            // file and could have the value be non-zero for certain builds, like
            // stub builds.
#pragma warning disable 162
            if (HEU_HoudiniVersion.HOUDINI_PATCH != 0)
            {
                correctVersionKey += "." + HEU_HoudiniVersion.HOUDINI_PATCH;
            }
#pragma warning restore 162

            string appPath = HEU_PlatformWin.GetRegistryKeyvalue_x64(HEU_PlatformWin.HKEY_LOCAL_MACHINE, HEU_HoudiniVersion.SIDEFX_SOFTWARE_REGISTRY + appName, correctVersionKey);
            if (appPath == null || appPath.Length == 0)
            {
                // Try 32-bit entry (for Steam builds)
                appPath = HEU_PlatformWin.GetRegistryKeyvalue_x86(HEU_PlatformWin.HKEY_LOCAL_MACHINE, HEU_HoudiniVersion.SIDEFX_SOFTWARE_REGISTRY + appName, correctVersionKey);
                if (appPath == null || appPath.Length == 0)
                {
                    throw new HEU_HoudiniEngineError(string.Format("Expected version {0} of {1} not found in the system registry!", correctVersion, appName));
                }
            }

            if (appPath.EndsWith("\\") || appPath.EndsWith("/"))
            {
                appPath = appPath.Remove(appPath.Length - 1);
            }

            return(appPath);
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Returns the path to the Houdini Engine plugin installation.
		/// </summary>
		/// <returns>Path to the Houdini Engine plugin installation.</returns>
		public static string GetHoudiniEnginePath()
		{
			string HAPIPath = null;

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN

			// Look up in environment variable
			HAPIPath = System.Environment.GetEnvironmentVariable(HEU_Defines.HAPI_PATH, System.EnvironmentVariableTarget.Machine);
			if(HAPIPath == null || HAPIPath.Length == 0)
			{
				HAPIPath = System.Environment.GetEnvironmentVariable(HEU_Defines.HAPI_PATH, System.EnvironmentVariableTarget.User);
			}
			if (HAPIPath == null || HAPIPath.Length == 0)
			{
				HAPIPath = System.Environment.GetEnvironmentVariable(HEU_Defines.HAPI_PATH, System.EnvironmentVariableTarget.Process);
			}

			if(HAPIPath == null || HAPIPath.Length == 0)
			{
				// HAPI_PATH not set. Look in registry.

				string[] houdiniAppNames = { "Houdini Engine", "Houdini" };

				foreach (string appName in houdiniAppNames)
				{
					try
					{
						HAPIPath = HEU_PlatformWin.GetApplicationPath(appName);
						break;
					}
					catch (HEU_HoudiniEngineError error)
					{
						_lastErrorMsg = error.ToString();
					}
				}

				//Debug.Log("HAPI Path: " + HAPIPath);

			}

#elif (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX)
			HAPIPath = HEU_HoudiniVersion.HOUDINI_INSTALL_PATH;
#else
			_lastErrorMsg = "Unable to find Houdini installation because this is an unsupported platform!";
#endif

			return HAPIPath;
		}