Beispiel #1
0
    public static void saveHoudiniScene(bool lock_nodes)
    {
        HAPI_License license = HoudiniHost.getCurrentLicense();
        string       ext     = "hip";

        if (license == HAPI_License.HAPI_LICENSE_HOUDINI_ENGINE_INDIE ||
            license == HAPI_License.HAPI_LICENSE_HOUDINI_INDIE)
        {
            ext = "hiplc";
        }

        string hip_file_path = EditorUtility.SaveFilePanel("Save HIP File", "", "hscene", ext);

        if (hip_file_path != "")
        {
            HoudiniHost.saveScene(hip_file_path, lock_nodes);
        }
    }
Beispiel #2
0
    protected void drawLicenseLogo()
    {
        if (HoudiniHost.getCurrentLicense() != HAPI_License.HAPI_LICENSE_HOUDINI_ENGINE_INDIE)
        {
            return;
        }

        HoudiniGUI.separator();

        int  skin          = EditorPrefs.GetInt("UserSkin");
        bool is_light_skin = skin == 0;

#if false
        if (myDarkSkinLogo == null && is_dark_skin)
        {
            myDarkSkinLogo = Resources.Load <Texture2D>("hEngine_white_color");
        }
        if (myLightSkinLogo == null && is_light_skin)
        {
            myLightSkinLogo = Resources.Load <Texture2D>("hEngine_black_color");
        }
        Texture2D logo = (is_light_skin ? myLightSkinLogo : myDarkSkinLogo);

        float pane_width = (float)Screen.width - 60;
        float ratio      = Mathf.Min(0.2f, pane_width / logo.width);

        GUIStyle image_style = new GUIStyle(GUI.skin.label);
        image_style.normal.background = logo;
        image_style.imagePosition     = ImagePosition.ImageAbove;
        EditorGUILayout.LabelField(
            "", image_style,
            GUILayout.Height(logo.height * ratio),
            GUILayout.Width(logo.width * ratio));
#endif

        GUIStyle label_style = new GUIStyle(GUI.skin.label);
        label_style.fontStyle        = FontStyle.Bold;
        label_style.normal.textColor = is_light_skin ? Color.red : Color.yellow;
        EditorGUILayout.LabelField("Houdini Engine Indie - For Limited Commercial Use Only", label_style);

        HoudiniGUI.separator();
    }
Beispiel #3
0
    public void OnGUI()
    {
        bool gui_enable = GUI.enabled;

#if !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || (UNITY_METRO && UNITY_EDITOR))
        HoudiniGUI.help(HoudiniConstants.HAPI_UNSUPPORTED_PLATFORM_MSG, MessageType.Info);
        GUI.enabled = false;
#else
        if (!HoudiniHost.isInstallationOk())
        {
            HoudiniGUI.help(
                HoudiniHost.getMissingEngineInstallHelpString(), MessageType.Info);
            GUI.enabled = false;
        }
#endif // !( UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || ( UNITY_METRO && UNITY_EDITOR ) )

        if (GUILayout.Button(HoudiniGUIUtility.myLoadAssetLabel))
        {
            string asset_file_path = HoudiniGUIUtility.promptForOTLPath();
            HoudiniAssetUtility.instantiateAsset(asset_file_path);
        }

        if (GUILayout.Button(HoudiniGUIUtility.myLoadHipLabel))
        {
            string hip_file_path = HoudiniGUIUtility.promptForHIPPath();
            HoudiniAssetUtility.loadHipFile(hip_file_path);
        }

        HoudiniGUI.separator();

        if (GUILayout.Button(HoudiniGUIUtility.mySaveHoudiniSceneLabel))
        {
            HAPI_License license = HoudiniHost.getCurrentLicense();
            string       ext     = "hip";

            if (license == HAPI_License.HAPI_LICENSE_HOUDINI_ENGINE_INDIE ||
                license == HAPI_License.HAPI_LICENSE_HOUDINI_INDIE)
            {
                ext = "hiplc";
            }

            string hip_file_path = EditorUtility.SaveFilePanel("Save HIP File", "", "hscene", ext);
            if (hip_file_path != "")
            {
                HoudiniHost.saveScene(hip_file_path, myLockNodesOnHipSave);
            }
        }
        {
            bool undo_value = myLockNodesOnHipSave;
            HoudiniGUI.toggle(
                "lock_nodes", "Lock Nodes On Scene Save",
                ref myLockNodesOnHipSave, null, ref undo_value);
        }

        HoudiniGUI.separator();

        if (GUILayout.Button("Check for New Untracked Asset Nodes"))
        {
            HoudiniAssetUtility.checkForNewAssets();
        }

        HoudiniGUI.separator();

        if (HoudiniGUI.floatField("global_time", "Global Time", ref myTime, null, ref myTime))
        {
            HoudiniHost.setTime(myTime);
        }

        HoudiniGUI.separator();

        string path = Application.dataPath;

        myScrollPosition = GUILayout.BeginScrollView(myScrollPosition);

        if (GUILayout.Button("Instantiate Core Assets"))
        {
            try
            {
                DirectoryInfo core = new DirectoryInfo(path + "//OTLs/Core");

                if (!core.Exists)
                {
                    throw new HoudiniError("Project/Assets/OTLs/Core directory does not exist!");
                }

                foreach (FileInfo fi in core.GetFiles())
                {
                    if (fi.Extension == ".otl")
                    {
                        loadOTL(fi);
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError("Directory navigation failed: " + e.ToString());
            }
        }

#if (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || (UNITY_METRO && UNITY_EDITOR))
        DirectoryInfo di = new DirectoryInfo(path + "//OTLs");

        try
        {
            if (!di.Exists)
            {
                throw new HoudiniError("Project/Assets/OTLs directory does not exist!");
            }

            foreach (DirectoryInfo child_directory in di.GetDirectories())
            {
                OTLDirectory otlDir = null;

                foreach (OTLDirectory existingOTLDir in myOTLDirectories)
                {
                    if (existingOTLDir.myDirectoryName == child_directory.Name)
                    {
                        otlDir = existingOTLDir;
                        break;
                    }
                }

                if (otlDir == null)
                {
                    otlDir = new OTLDirectory();
                    otlDir.myDirectoryName = child_directory.Name;
                    otlDir.myDirectoryPath = child_directory.FullName;
                    otlDir.myExpanded      = false;
                    myOTLDirectories.Add(otlDir);
                }

                otlDir.myExpanded =
                    EditorGUILayout.Foldout(otlDir.myExpanded, new GUIContent(otlDir.myDirectoryName));

                if (otlDir.myDirectoryName == "Core")
                {
                    otlDir.myExpanded = true;
                }

                if (otlDir.myExpanded)
                {
                    DirectoryInfo dirContents = new DirectoryInfo(otlDir.myDirectoryPath);

                    foreach (FileInfo fi in dirContents.GetFiles())
                    {
                        if (fi.Extension == ".otl")
                        {
                            genOTLEntry(fi);
                        }
                    }
                }
            }
        }
        catch (System.Exception e)
        {
            Debug.LogError("Directory navigation failed: " + e.ToString());
        }
#endif // ( UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || ( UNITY_METRO && UNITY_EDITOR ) )

        GUILayout.EndScrollView();

        GUI.enabled = gui_enable;
    }