Esempio n. 1
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Private

    private static void generateGeneralSettings()
    {
        // Pin Size
        {
            float value   = HoudiniHost.prPinSize;
            bool  changed = HoudiniGUI.floatField(
                "pin_size", "Pin Size", ref value,
                myUndoInfo, ref myUndoInfo.pinSize);
            if (changed)
            {
                HoudiniHost.prPinSize = value;
                HoudiniHost.repaint();
            }
        }

        // Pin Colour
        {
            Color value   = HoudiniHost.prPinColour;
            bool  changed = HoudiniGUI.colourField(
                "pin_colour", "Pin Color", ref value,
                myUndoInfo, ref myUndoInfo.pinColour);
            if (changed)
            {
                HoudiniHost.prPinColour = value;
                HoudiniHost.repaint();
            }
        }

        // Auto pin
        {
            bool value   = HoudiniHost.prAutoPinInstances;
            bool changed = HoudiniGUI.toggle(
                "auto_pin_instances", "Auto Pin Instances",
                ref value, myUndoInfo,
                ref myUndoInfo.autoPinInstances);
            if (changed)
            {
                HoudiniHost.prAutoPinInstances = value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Enable Support Warnings
        {
            bool value   = HoudiniHost.prEnableSupportWarnings;
            bool changed = HoudiniGUI.toggle(
                "enable_support_warnings", "Enable Support Warnings",
                ref value, myUndoInfo,
                ref myUndoInfo.enableSupportWarnings);
            if (changed)
            {
                HoudiniHost.prEnableSupportWarnings = value;
            }
        }
    }
Esempio n. 2
0
    private static void generateMaterialSettings()
    {
        // Gamma
        {
            float value   = HoudiniHost.prGamma;
            bool  changed = HoudiniGUI.floatField(
                "gamma", "Gamma", ref value,
                myUndoInfo, ref myUndoInfo.gamma);
            if (changed)
            {
                HoudiniHost.prGamma = value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Don't Create Texture Files
        {
            bool value   = HoudiniHost.prDontCreateTextureFiles;
            bool changed = HoudiniGUI.toggle(
                "dont_create_texture_files",
                "Don't Create Texture Files (use in-memory textures)",
                ref value, myUndoInfo, ref myUndoInfo.dontCreateTextureFiles);
            if (changed)
            {
                HoudiniHost.prDontCreateTextureFiles = value;
                HoudiniHost.repaint();

                EditorUtility.DisplayDialog(
                    "Rebuilds Required",
                    "This change will take affect for new instantiations or rebuilds.\n" +
                    "A full Unity restart is recommended.",
                    "Ok");
            }
        }

        // Extract Textures In Raw Format
        {
            bool value           = HoudiniHost.prExtractTexturesInRawFormat;
            bool was_gui_enabled = GUI.enabled;
            GUI.enabled = HoudiniHost.prDontCreateTextureFiles;
            bool changed = HoudiniGUI.toggle(
                "extract_textures_in_raw_format",
                "Extract Textures In Raw Format (only works for in-memory textures)",
                ref value, myUndoInfo, ref myUndoInfo.extractTexturesInRawFormat);
            if (changed)
            {
                HoudiniHost.prExtractTexturesInRawFormat = value;
                HoudiniHost.repaint();
            }
            GUI.enabled = was_gui_enabled;
        }
    }
Esempio n. 3
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Private

    private void generateAssetBakeControls()
    {
        // Start Time
        {
            float value   = myAsset.prBakeStartTime;
            bool  changed = HoudiniGUI.floatField(
                "bake_start_time", "Start Time", ref value,
                myUndoInfo, ref myUndoInfo.bakeStartTime);

            if (changed)
            {
                myAsset.prBakeStartTime = value;
            }
        }

        // End Time
        {
            float value   = myAsset.prBakeEndTime;
            bool  changed = HoudiniGUI.floatField(
                "bake_end_time", "End Time", ref value,
                myUndoInfo, ref myUndoInfo.bakeEndTime);
            if (changed)
            {
                myAsset.prBakeEndTime = value;
            }
        }

        // Samples per second
        {
            int  value   = myAsset.prBakeSamplesPerSecond;
            bool changed = HoudiniGUI.intField(
                "bake_samples_per_second", "Samples Per Second", ref value,
                1, 120, myUndoInfo, ref myUndoInfo.bakeSamplesPerSecond);

            if (changed)
            {
                myAsset.prBakeSamplesPerSecond = value;
            }
        }

        if (GUILayout.Button("Bake Animation"))
        {
            HoudiniProgressBar progress_bar = new HoudiniProgressBar();
            progress_bar.prUseDelay = false;
            myAsset.bakeAnimations(
                myAsset.prBakeStartTime,
                myAsset.prBakeEndTime,
                myAsset.prBakeSamplesPerSecond,
                myAsset.gameObject,
                progress_bar);
            progress_bar.clearProgressBar();
        }
    }
Esempio n. 4
0
    public void OnGUI()
    {
        bool gui_enable = GUI.enabled;

#if !( HAPI_ENABLE_RUNTIME )
        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 // !( HAPI_ENABLE_RUNTIME )

        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))
        {
            HoudiniGUIUtility.saveHoudiniScene(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 ( HAPI_ENABLE_RUNTIME )
        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 // ( HAPI_ENABLE_RUNTIME )

        GUILayout.EndScrollView();

        GUI.enabled = gui_enable;
    }
    protected bool generateAssetControl(int index, ref bool join_last, ref bool no_label_toggle_last)
    {
        if (myParms.prParms == null)
        {
            return(false);
        }

        if (myParms.prParms[index].invisible)
        {
            return(false);
        }

        bool changed = false;

        HAPI_ParmInfo[]      parms        = myParms.prParms;
        HAPI_ParmInfo        parm         = parms[index];
        HAPI_ParmInfoStrings parm_strings = myParms.prParmInfoStrings[index];

        int[]   parm_int_values   = myParms.prParmIntValues;
        float[] parm_float_values = myParms.prParmFloatValues;

        HoudiniGUIParm gui_parm = new HoudiniGUIParm(parm, parm_strings);

        ///////////////////////////////////////////////////////////////////////
        // Integer Parameter
        if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_MULTIPARMLIST)
        {
            changed = HoudiniGUI.multiparmField(
                ref gui_parm, ref myDelayBuild, ref parm_int_values,
                ref join_last, ref no_label_toggle_last);
        }
        else if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_INT)
        {
            if (parm.choiceCount > 0 && parm.choiceIndex >= 0)
            {
                // Draw popup (menu) field.
                List <string> labels = new List <string>();
                List <int>    values = new List <int>();

                // Go through our choices.
                for (int i = 0; i < parm.choiceCount; ++i)
                {
                    if (myParms.prParmChoiceLists[parm.choiceIndex + i].parentParmId != parm.id)
                    {
                        Debug.LogError("Parm choice parent parm id ("
                                       + myParms.prParmChoiceLists[parm.choiceIndex + i].parentParmId
                                       + ") not matching current parm id (" + parm.id + ")!\n"
                                       + "Choice index: " + (parm.choiceIndex + i) + ", "
                                       + "Choice count: " + parm.choiceCount);
                    }

                    labels.Add(myParms.prParmChoiceInfoStrings[parm.choiceIndex + i].label);
                    values.Add(i);
                }

                changed = HoudiniGUI.dropdown(
                    ref gui_parm, ref parm_int_values,
                    labels.ToArray(), values.ToArray(),
                    ref join_last, ref no_label_toggle_last,
                    null, ref parm_int_values);
            }
            else
            {
                changed = HoudiniGUI.intField(
                    ref gui_parm, ref myDelayBuild, ref parm_int_values,
                    ref join_last, ref no_label_toggle_last, null,
                    ref parm_int_values);
            }     // if parm.choiceCount
        }         // if parm.type is INT
        ///////////////////////////////////////////////////////////////////////
        // Float Parameter
        else if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_FLOAT)
        {
            changed = HoudiniGUI.floatField(
                ref gui_parm, ref myDelayBuild, ref parm_float_values,
                ref join_last, ref no_label_toggle_last, null,
                ref parm_float_values);
        }         // if parm.type is FLOAT
        ///////////////////////////////////////////////////////////////////////
        // String Parameter
        else if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_STRING)
        {
            if (parm.choiceCount > 0 && parm.choiceIndex >= 0)
            {
                // Draw popup (menu) field.
                List <string> labels = new List <string>();
                List <string> values = new List <string>();

                // Go through our choices.
                for (int i = 0; i < parm.choiceCount; ++i)
                {
                    if (myParms.prParmChoiceLists[parm.choiceIndex + i].parentParmId != parm.id)
                    {
                        Debug.LogError(
                            "Parm choice parent parm id ("
                            + myParms.prParmChoiceLists[parm.choiceIndex + i].parentParmId
                            + ") not matching current parm id (" + parm.id + ")!\n"
                            + "Choice index: " + (parm.choiceIndex + i) + ", "
                            + "Choice count: " + parm.choiceCount);
                    }

                    labels.Add(myParms.prParmChoiceInfoStrings[parm.choiceIndex + i].label);
                    values.Add(myParms.prParmChoiceInfoStrings[parm.choiceIndex + i].value);
                }

                string[] values_temp = myParms.getParmStrings(parm);
                gui_parm.valuesIndex = 0;                 // Since we're piping a de-handled temp array.

                changed = HoudiniGUI.dropdown(
                    ref gui_parm, ref values_temp,
                    labels.ToArray(), values.ToArray(),
                    ref join_last, ref no_label_toggle_last,
                    null, ref values_temp);

                if (changed)
                {
                    myParms.setParmStrings(parm, values_temp);
                }
            }
            else
            {
                string[] values = myParms.getParmStrings(parm);

                // The given string array is only for this parm so we need to set the values index to 0.
                gui_parm.valuesIndex = 0;

                changed = HoudiniGUI.stringField(
                    ref gui_parm, ref myDelayBuild, ref values,
                    ref join_last, ref no_label_toggle_last, null,
                    ref values);

                // Set the to be changed strings into the cache
                if (changed)
                {
                    myParms.setParmStrings(parm, values);
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////
        // File Path Field
        else if (parm.isPath())
        {
            string[] path = myParms.getParmStrings(parm);

            if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_PATH_FILE_GEO)
            {
                gui_parm.label += " (geo)";
            }
            else if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_PATH_FILE_IMAGE)
            {
                gui_parm.label += " (image)";
            }

            // Asset ID might still be invalid here so don't fail if it is.
            // It is invalid if the asset didn't cook yet after a scene load.
            try
            {
                string file_pattern = parm.typeInfo;
                if (file_pattern != "")
                {
                    gui_parm.label += " (" + file_pattern + ")";
                }
            }
            catch {}

            HAPI_Permissions permissions = parm.permissions;
            if (permissions == HAPI_Permissions.HAPI_PERMISSIONS_READ_ONLY)
            {
                gui_parm.label += " (read-only)";
                changed         = HoudiniGUI.fileOpenField(
                    ref gui_parm, ref myDelayBuild, ref path[0],
                    ref join_last, ref no_label_toggle_last);
            }
            else
            {
                if (permissions == HAPI_Permissions.HAPI_PERMISSIONS_WRITE_ONLY)
                {
                    gui_parm.label += " (write-only)";
                }

                changed = HoudiniGUI.fileSaveField(
                    ref gui_parm, ref myDelayBuild, ref path[0],
                    ref join_last, ref no_label_toggle_last);
            }

            if (changed)
            {
                myParms.setParmStrings(parm, path);
            }
        }
        ///////////////////////////////////////////////////////////////////////
        // Node Path Field
        else if (parm.isNode())
        {
            // Asset ID might still be invalid here so don't fail if it is.
            // It is invalid if the asset didn't cook yet after a scene load.
            try
            {
                string op_filter = parm.typeInfo;
                if (op_filter != "")
                {
                    gui_parm.label += " (" + op_filter + ")";
                }
            }
            catch {}

            HAPI_ParmInput     parm_input  = myParms.prParmInputs[parm.id];
            UnityEngine.Object temp_object = parm_input.inputObject;
            GameObject         undo_object = null;
            changed = HoudiniGUI.objectField(
                ref gui_parm, ref temp_object, typeof(GameObject),
                ref join_last, ref no_label_toggle_last, null, ref undo_object);

            if (changed)
            {
                parm_input.newInputObject   = (GameObject)temp_object;
                myParms.prParmInputs[index] = parm_input;
            }
        }
        ///////////////////////////////////////////////////////////////////////
        // Toggle Parameter
        else if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_TOGGLE)
        {
            changed = HoudiniGUI.toggle(
                ref gui_parm, ref parm_int_values,
                ref join_last, ref no_label_toggle_last,
                null, ref parm_int_values);
        }
        ///////////////////////////////////////////////////////////////////////
        // Color Parameter
        else if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_COLOR)
        {
            changed = HoudiniGUI.colourField(
                ref gui_parm, ref myDelayBuild, ref parm_float_values,
                ref join_last, ref no_label_toggle_last, null,
                ref parm_float_values);
        }
        ///////////////////////////////////////////////////////////////////////
        // Button Parameter
        else if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_BUTTON)
        {
            if (parm.choiceCount > 0 && parm.choiceIndex >= 0)
            {
                // Draw popup (menu) field.
                List <string> labels = new List <string>();
                List <int>    values = new List <int>();

                // Go through our choices.
                for (int i = 0; i < parm.choiceCount; ++i)
                {
                    if (myParms.prParmChoiceLists[parm.choiceIndex + i].parentParmId != parm.id)
                    {
                        Debug.LogError(
                            "Parm choice parent parm id ("
                            + myParms.prParmChoiceLists[parm.choiceIndex + i].parentParmId
                            + ") not matching current parm id (" + parm.id + ")!\n"
                            + "Choice index: " + (parm.choiceIndex + i) + ", "
                            + "Choice count: " + parm.choiceCount);
                    }

                    labels.Add(myParms.prParmChoiceInfoStrings[parm.choiceIndex + i].label);
                    values.Add(i);
                }

                changed = HoudiniGUI.dropdown(
                    ref gui_parm, ref parm_int_values,
                    labels.ToArray(), values.ToArray(),
                    ref join_last, ref no_label_toggle_last,
                    null, ref parm_int_values);
            }
            else
            {
                changed = HoudiniGUI.button(ref gui_parm, ref join_last, ref no_label_toggle_last);
            }
        }
        ///////////////////////////////////////////////////////////////////////
        // Label
        else if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_LABEL)
        {
            HoudiniGUI.label(ref gui_parm, ref join_last, ref no_label_toggle_last);
        }
        ///////////////////////////////////////////////////////////////////////
        // Separator
        else if (parm.type == HAPI_ParmType.HAPI_PARMTYPE_SEPARATOR)
        {
            HoudiniGUI.separator();
        }

        if (myAsset.hasProgressBarBeenUsed() && parm.id == myParms.prLastChangedParmId)
        {
            // TODO: Set the focus back to this control since the progress bar would have stolen it.
        }


        if (changed)
        {
            myParms.prLastChangedParmId = parm.id;
        }

        return(changed);
    }
Esempio n. 6
0
    private static void generateGeometrySettings()
    {
        // Paint Brush Rate
        {
            // Everything is opposite here because the higher the number the slower
            // the paint rate and we want the user to think the higher the number
            // the FASTER the rate - so we have to invert.
            float value   = HoudiniHost.prPaintBrushRate;
            bool  changed = HoudiniGUI.floatField(
                "paint_brush_rate", "Paint Brush Rate",
                ref value, 0.0f, 1.0f,
                myUndoInfo,
                ref myUndoInfo.paintBrushRate);
            if (changed)
            {
                HoudiniHost.prPaintBrushRate = value;
                HoudiniHost.repaint();
            }
        }

        // Painting Mode Hot Key
        {
            KeyCode  value  = HoudiniHost.prPaintingModeHotKey;
            string[] labels =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .Select(v => v.ToString())
                .ToArray();
            KeyCode[] values =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .ToArray();
            bool changed = HoudiniGUI.dropdown(
                "painting_mode_hot_key", "Painting Key",
                ref value, labels, values, myUndoInfo,
                ref myUndoInfo.paintingModeHotKey);

            if (changed)
            {
                HoudiniHost.prPaintingModeHotKey = (KeyCode)value;
                HoudiniHost.repaint();
            }
        }

        // Painting Mode Colour
        {
            Color value   = HoudiniHost.prPaintingModeColour;
            bool  changed = HoudiniGUI.colourField(
                "painting_mode_colour", "Painting Mode",
                ref value, myUndoInfo,
                ref myUndoInfo.paintingModeColour);

            if (changed)
            {
                HoudiniHost.prPaintingModeColour = value;
                HoudiniHost.repaint();
            }
        }

        // Painting Node Switch Hot Key
        {
            KeyCode  value  = HoudiniHost.prPaintingNodeSwitchHotKey;
            string[] labels =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .Select(v => v.ToString())
                .ToArray();
            KeyCode[] values =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .ToArray();
            bool changed = HoudiniGUI.dropdown(
                "painting_node_switch_hot_key", "Node Switch Key",
                ref value, labels, values, myUndoInfo,
                ref myUndoInfo.paintingNodeSwitchHotKey);

            if (changed)
            {
                HoudiniHost.prPaintingNodeSwitchHotKey = (KeyCode)value;
                HoudiniHost.repaint();
            }
        }

        // Painting Attribute Switch Hot Key
        {
            KeyCode  value  = HoudiniHost.prPaintingAttributeSwitchHotKey;
            string[] labels =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .Select(v => v.ToString())
                .ToArray();
            KeyCode[] values =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .ToArray();
            bool changed = HoudiniGUI.dropdown(
                "painting_attribute_switch_hot_key", "Attr. Switch Key",
                ref value, labels, values, myUndoInfo,
                ref myUndoInfo.paintingAttributeSwitchHotKey);

            if (changed)
            {
                HoudiniHost.prPaintingAttributeSwitchHotKey = (KeyCode)value;
                HoudiniHost.repaint();
            }
        }

        // Painting Value Change Hot Key
        {
            KeyCode  value  = HoudiniHost.prPaintingValueChangeHotKey;
            string[] labels =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .Select(v => v.ToString())
                .ToArray();
            KeyCode[] values =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .ToArray();
            bool changed = HoudiniGUI.dropdown(
                "painting_value_change_hot_key", "Value Change Key",
                ref value, labels, values, myUndoInfo,
                ref myUndoInfo.paintingValueChangeHotKey);

            if (changed)
            {
                HoudiniHost.prPaintingValueChangeHotKey = (KeyCode)value;
                HoudiniHost.repaint();
            }
        }

        // Painting Falloff Change Hot Key
        {
            KeyCode  value  = HoudiniHost.prPaintingFalloffChangeHotKey;
            string[] labels =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .Select(v => v.ToString())
                .ToArray();
            KeyCode[] values =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .ToArray();
            bool changed = HoudiniGUI.dropdown(
                "painting_falloff_change_hot_key", "Falloff Change Key",
                ref value, labels, values, myUndoInfo,
                ref myUndoInfo.paintingFalloffChangeHotKey);

            if (changed)
            {
                HoudiniHost.prPaintingFalloffChangeHotKey = (KeyCode)value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Adding Points Mode Hot Key
        {
            KeyCode  value  = HoudiniHost.prAddingPointsModeHotKey;
            string[] labels =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .Select(v => v.ToString())
                .ToArray();
            KeyCode[] values =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .ToArray();

            bool changed = HoudiniGUI.dropdown(
                "adding_points_mode_hot_key", "Adding Points Key",
                ref value, labels, values, myUndoInfo,
                ref myUndoInfo.addingPointsModeHotKey);

            if (changed)
            {
                HoudiniHost.prAddingPointsModeHotKey = (KeyCode)value;
                HoudiniHost.repaint();
            }
        }

        // Adding Points Mode Colour
        {
            Color value   = HoudiniHost.prAddingPointsModeColour;
            bool  changed = HoudiniGUI.colourField(
                "adding_ponits_mode_colour", "Adding Points Mode",
                ref value, myUndoInfo,
                ref myUndoInfo.addingPointsModeColour);

            if (changed)
            {
                HoudiniHost.prAddingPointsModeColour = value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Editing Points Mode Hot Key
        {
            KeyCode  value  = HoudiniHost.prEditingPointsModeHotKey;
            string[] labels =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .Select(v => v.ToString())
                .ToArray();
            KeyCode[] values =
                System.Enum.GetValues(typeof(KeyCode))
                .Cast <KeyCode>()
                .ToArray();

            bool changed = HoudiniGUI.dropdown(
                "editing_points_mode_hot_key", "Editing Points Key",
                ref value, labels, values, myUndoInfo,
                ref myUndoInfo.editingPointsModeHotKey);

            if (changed)
            {
                HoudiniHost.prEditingPointsModeHotKey = (KeyCode)value;
                HoudiniHost.repaint();
            }
        }

        // Editing Points Mode Colour
        {
            Color value   = HoudiniHost.prEditingPointsModeColour;
            bool  changed = HoudiniGUI.colourField(
                "editing_ponits_mode_colour", "Editing Points Mode",
                ref value, myUndoInfo,
                ref myUndoInfo.editingPointsModeColour);
            if (changed)
            {
                HoudiniHost.prEditingPointsModeColour = value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Wireframe Colour
        {
            Color value   = HoudiniHost.prWireframeColour;
            bool  changed = HoudiniGUI.colourField(
                "wireframe_colour", "Wireframe", ref value,
                myUndoInfo, ref myUndoInfo.wireframeColour);
            if (changed)
            {
                HoudiniHost.prWireframeColour = value;
                HoudiniHost.repaint();
            }
        }

        // Guide Wireframe Colour
        {
            Color value   = HoudiniHost.prGuideWireframeColour;
            bool  changed = HoudiniGUI.colourField(
                "guide_wireframe_colour", "Guide Wireframe",
                ref value, myUndoInfo,
                ref myUndoInfo.guideWireframeColour);
            if (changed)
            {
                HoudiniHost.prGuideWireframeColour = value;
                HoudiniHost.repaint();
            }
        }

        // Unselectable Guide Wireframe Colour
        {
            Color value   = HoudiniHost.prUnselectableGuideWireframeColour;
            bool  changed = HoudiniGUI.colourField(
                "unselectable_guide_wireframe_colour",
                "Unselectable Guide",
                ref value, myUndoInfo,
                ref myUndoInfo.unselectableGuideWireframeColour);
            if (changed)
            {
                HoudiniHost.prUnselectableGuideWireframeColour = value;
                HoudiniHost.repaint();
            }
        }

        // Unselected Guide Wireframe Colour
        {
            Color value   = HoudiniHost.prUnselectedGuideWireframeColour;
            bool  changed = HoudiniGUI.colourField(
                "unselected_guide_wireframe_colour",
                "Unselected Guide",
                ref value, myUndoInfo,
                ref myUndoInfo.unselectedGuideWireframeColour);
            if (changed)
            {
                HoudiniHost.prUnselectedGuideWireframeColour = value;
                HoudiniHost.repaint();
            }
        }

        // Selected Guide Wireframe Colour
        {
            Color value   = HoudiniHost.prSelectedGuideWireframeColour;
            bool  changed = HoudiniGUI.colourField(
                "selected_guide_wireframe_colour",
                "Selected Guide",
                ref value, myUndoInfo,
                ref myUndoInfo.selectedGuideWireframeColour);
            if (changed)
            {
                HoudiniHost.prSelectedGuideWireframeColour = value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Guide Point Size
        {
            float value   = HoudiniHost.prGuidePointSize;
            bool  changed = HoudiniGUI.floatField(
                "guide_point_size", "Guide Point Size",
                ref value, 4.0f, 40.0f,
                myUndoInfo,
                ref myUndoInfo.guidePointSize);
            if (changed)
            {
                HoudiniHost.prGuidePointSize = value;
                HoudiniHost.repaint();
            }
        }

        // Min. Distance For Point Selection
        {
            float value   = HoudiniHost.prMinDistanceForPointSelection;
            bool  changed = HoudiniGUI.floatField(
                "min_distance_for_point_selection",
                "Min. Distance For Point Selection",
                ref value, 1.0f, 20.0f,
                myUndoInfo,
                ref myUndoInfo.minDistanceForPointSelection);
            if (changed)
            {
                HoudiniHost.prMinDistanceForPointSelection = value;
                HoudiniHost.repaint();
            }
        }

        // Guide Min. Distance For Mid Point Insertion
        {
            float value   = HoudiniHost.prGuideMinDistanceForMidPointInsertion;
            bool  changed = HoudiniGUI.floatField(
                "guide_min_distance_for_mid_point_insertion",
                "Guide Min. Distance For Mid Point Insertion",
                ref value, 1.0f, 20.0f,
                myUndoInfo,
                ref myUndoInfo.guideMinDistanceForMidPointInsertion);
            if (changed)
            {
                HoudiniHost.prGuideMinDistanceForMidPointInsertion = value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Create Groups from Bool Attribute
        {
            bool value   = HoudiniHost.prCreateGroupsFromBoolAttributes;
            bool changed = HoudiniGUI.toggle(
                "create_groups_from_bool_attributes", "Create Groups from Bool Attributes",
                ref value, myUndoInfo,
                ref myUndoInfo.createGroupsFromBoolAttributes);
            if (changed)
            {
                HoudiniHost.prCreateGroupsFromBoolAttributes = value;
                HoudiniHost.repaint();
            }
        }
    }
Esempio n. 7
0
    private void generateAssetInstanceControls()
    {
        HoudiniInstancerManager instancer_manager = myAssetOTL.gameObject.GetComponent <HoudiniInstancerManager>();

        if (instancer_manager == null)
        {
            return;
        }

        List <HoudiniInstancerPersistentData> instancer_persistent_data = instancer_manager.prInstancerPersistentData;

        HoudiniInstancer[] instancers = myAssetOTL.gameObject.GetComponentsInChildren <HoudiniInstancer>();

        foreach (HoudiniInstancer instancer in instancers)
        {
            HoudiniInstancerPersistentData persistent_data = null;

            for (int ii = 0; ii < instancer_persistent_data.Count; ii++)
            {
                HoudiniInstancerPersistentData data = instancer_persistent_data[ii];
                if (data.instancerName == instancer.name)
                {
                    persistent_data = data;
                    break;
                }
            }

            if (persistent_data == null)
            {
                Debug.LogError("Can't find persistent data for instancer: " + instancer.name);
                continue;
            }

            Undo.RecordObject(persistent_data, "Houdini Instancer Change");

            persistent_data.showInstancerGUI = HoudiniGUI.foldout(
                persistent_data.instancerName, persistent_data.showInstancerGUI, true);
            if (persistent_data.showInstancerGUI)
            {
                bool changed = false;

                {
                    Vector3 dummy = new Vector3();
                    changed |= HoudiniGUI.floatField(
                        "RotationOffset", "Rotation Offset",
                        ref persistent_data.rotationalOffset, null, ref dummy);

                    changed |= HoudiniGUI.floatField(
                        "ScaleOffset", "Scale Offset", ref persistent_data.scaleOffset, null, ref dummy);

                    List <string> unique_names = persistent_data.uniqueNames;

                    for (int ii = 0; ii < unique_names.Count; ii++)
                    {
                        string instanced_name = unique_names[ii];
                        int    base_index     = persistent_data.baseIndex(ii);



                        for (int jj = 0; jj < persistent_data.numObjsToInstantiate[ii]; jj++)
                        {
                            Object obj = (Object)persistent_data.objsToInstantiate[base_index + jj];

                            GUILayout.BeginHorizontal();



                            string label = "";
                            if (jj == 0)
                            {
                                label = instanced_name;
                            }

                            changed |= HoudiniGUI.objectField(
                                "object_to_instantiate", label, ref obj, typeof(GameObject));

                            if (changed)
                            {
                                persistent_data.objsToInstantiate[base_index + jj] = (GameObject)obj;
                            }

                            if (GUILayout.Button("+"))
                            {
                                persistent_data.objsToInstantiate.Insert
                                    (base_index + jj, null);
                                persistent_data.numObjsToInstantiate[ii]++;
                                persistent_data.recalculateVariations[ii] = true;
                                changed = true;
                                break;
                            }

                            if (GUILayout.Button("-"))
                            {
                                if (persistent_data.numObjsToInstantiate[ii] == 1)
                                {
                                    persistent_data.objsToInstantiate[base_index] = null;
                                }
                                else
                                {
                                    persistent_data.objsToInstantiate.RemoveAt(base_index + jj);
                                    persistent_data.numObjsToInstantiate[ii]--;
                                }
                                persistent_data.recalculateVariations[ii] = true;
                                changed = true;
                                break;
                            }

                            GUILayout.EndHorizontal();
                        }
                    }

                    if (GUILayout.Button("Recalculate Variations"))
                    {
                        for (int ii = 0; ii < unique_names.Count; ii++)
                        {
                            persistent_data.recalculateVariations[ii] = true;
                        }
                        changed = true;
                    }
                }


                if (instancer.hasOverriddenInstances())
                {
                    if (GUILayout.Button("UnPin All Instances"))
                    {
                        instancer.unPinAllInstances();
                        changed = true;
                    }
                }

                if (changed)
                {
                    HoudiniProgressBar progress_bar = new HoudiniProgressBar();
                    instancer.instanceObjects(progress_bar);
                    progress_bar.clearProgressBar();

                    for (int ii = 0; ii < persistent_data.recalculateVariations.Count; ii++)
                    {
                        persistent_data.recalculateVariations[ii] = false;
                    }
                }
            }

            EditorGUILayout.Separator();
        }
    }
    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.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);
            }
        }

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

        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;
    }
Esempio n. 9
0
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Private
	
	private static void generateGeneralSettings()
	{
		// Pin Size
		{
			float value = HoudiniHost.prPinSize;
			bool changed = HoudiniGUI.floatField(
				"pin_size", "Pin Size", ref value, 
				myUndoInfo, ref myUndoInfo.pinSize );
			if ( changed )
			{
				HoudiniHost.prPinSize = value;
				HoudiniHost.repaint();
			}
		}

		// Pin Colour
		{
			Color value = HoudiniHost.prPinColour;
			bool changed = HoudiniGUI.colourField(
				"pin_colour", "Pin Color", ref value,
				myUndoInfo, ref myUndoInfo.pinColour );
			if ( changed )
			{
				HoudiniHost.prPinColour = value;
				HoudiniHost.repaint();
			}
		}

		// Auto pin
		{
			bool value = HoudiniHost.prAutoPinInstances;
			bool changed = HoudiniGUI.toggle(
				"auto_pin_instances", "Auto Pin Instances", 
				ref value, myUndoInfo,
				ref myUndoInfo.autoPinInstances );
			if ( changed )
			{
				HoudiniHost.prAutoPinInstances = value;
				HoudiniHost.repaint();
			}
		}

		HoudiniGUI.separator();

		// Enable Support Warnings
		{
			bool value = HoudiniHost.prEnableSupportWarnings;
			bool changed = HoudiniGUI.toggle(
				"enable_support_warnings", "Enable Support Warnings", 
				ref value, myUndoInfo,
				ref myUndoInfo.enableSupportWarnings );
			if ( changed )
				HoudiniHost.prEnableSupportWarnings = value;
		}

		HoudiniGUI.separator();

		// Auto Select Asset Root Node
		{
			bool value = HoudiniHost.prAutoSelectAssetRootNode;
			bool changed = HoudiniGUI.toggle(
				"auto_select_asset_root_node", 
				"Auto Select Asset Root Node", 
				ref value, myUndoInfo,
				ref myUndoInfo.autoSelectAssetRootNode );
			if ( changed )
			{
				HoudiniHost.prAutoSelectAssetRootNode = value;
				HoudiniHost.repaint();
			}
		}

		HoudiniGUI.separator();

		// Enable particles
		{
			bool value = HoudiniHost.prEnablePointsAsParticles;
			bool changed = HoudiniGUI.toggle(
				"enable_points_as_particles",
				"Create Points as Particles", 
				ref value, myUndoInfo,
				ref myUndoInfo.enablePointsAsParticles );
			if ( changed )
			{
				HoudiniHost.prEnablePointsAsParticles = value;
			}
		}
	}