Beispiel #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;
            }
        }
    }
Beispiel #2
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 ) )

		myUndoInfo = HoudiniHost.prHostUndoInfo;
		myScrollPosition = GUILayout.BeginScrollView( myScrollPosition );

		if ( GUILayout.Button( HoudiniGUIUtility.myRevertAllSettingsLabel ) )
		{
			if ( EditorUtility.DisplayDialog(
				"Revert all settings?",
				"Are you sure you want to revert ALL Houdini plugin settings?", 
				"Yes", "No" ) )
			{
				HoudiniHost.revertAllSettingsToDefaults();
				HoudiniHost.repaint();
			}
		}

		HoudiniGUI.separator();

		GUIContent[] modes = new GUIContent[ 6 ];
		modes[ 0 ] = new GUIContent( "General" );
		modes[ 1 ] = new GUIContent( "Materials" );
		modes[ 2 ] = new GUIContent( "Cooking" );
		modes[ 3 ] = new GUIContent( "Geometry" );
		modes[ 4 ] = new GUIContent( "Curves" );
		modes[ 5 ] = new GUIContent( "Advanced" );
		mySettingsTabSelection = GUILayout.Toolbar( mySettingsTabSelection, modes );

		switch ( mySettingsTabSelection )
		{
			case 0: generateGeneralSettings(); break;
			case 1: generateMaterialSettings(); break;
			case 2: generateCookingSettings(); break;
			case 3: generateGeometrySettings(); break;
			case 4: generateCurveSettings(); break;
			case 5: generateAdvancedSettings(); break;
			default: Debug.LogError( "Invalid Settings Tab." ); break;
		}

		GUILayout.EndScrollView();

		GUI.enabled = gui_enable;
	}
Beispiel #3
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;
        }
    }
Beispiel #4
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();
    }
    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 generateAssetControls()
    {
        if (myParms.prParms == null)
        {
            return(false);
        }

        bool changed       = false;
        int  current_index = 0;

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

        bool join_last            = false;
        bool no_label_toggle_last = false;

        int folder_list_count = 0;

        // These stacks maintain the current folder depth, parent id, and how many more child
        // parameters are still contained in the current folder.
        Stack <int> parent_id_stack    = new Stack <int>();
        Stack <int> parent_count_stack = new Stack <int>();
        int         instance_length    = -1;

        // Loop through all the parameters.
        while (current_index < myParms.prParmCount)
        {
            int current_parent_id = HoudiniConstants.HAPI_INVALID_PARM_ID;             // The root has parent id -1.

            // If we're not at the root (empty parent stack), get the current parent id and parent
            // count from the stack as well as decrement the parent count as we're about to parse
            // another parameter.
            if (parent_id_stack.Count != 0)
            {
                current_parent_id = parent_id_stack.Peek();

                // Get the leftover parameter count of the current folder.
                int current_parent_count = parent_count_stack.Peek();

                // The only reason current_parent_count would be 0 at this point is if we start off
                // with an empty folder. Pop it and move on, but do not increment the current_index!
                if (current_parent_count <= 0)
                {
                    parent_id_stack.Pop();
                    parent_count_stack.Pop();
                    continue;
                }

                // If the current parameter, whatever it may be, does not belong to the current active
                // parent then skip it. This check has to be done here because we do not want to
                // increment the top of the parent_count_stack as if we included a parameter in the
                // current folder.
                if (parms[current_index].parentId != current_parent_id)
                {
                    current_index++;
                    continue;
                }

                // Decrement the leftover parameter count.
                current_parent_count--;

                // If we've reached the last parameter in the current folder we need to pop the parent
                // stacks (we're done with the current folder). Otherwise, update the top of the
                // parent_count_stack.
                if (current_parent_count <= 0)
                {
                    parent_id_stack.Pop();
                    parent_count_stack.Pop();
                }
                else
                {
                    parent_count_stack.Pop();
                    parent_count_stack.Push(current_parent_count);
                }
            }
            else if (parms[current_index].parentId != current_parent_id)
            {
                // If the current parameter does not belong to the current active parent then skip it.
                current_index++;
                continue;
            }

            if (parms[current_index].type == HAPI_ParmType.HAPI_PARMTYPE_MULTIPARMLIST)
            {
                changed |= generateAssetControl(current_index, ref join_last, ref no_label_toggle_last);

                //int instance_count = myParms.prParmIntValues[ parms[ current_index ].intValuesIndex ];
                int instance_count = parms[current_index].instanceCount;
                instance_length = parms[current_index].instanceLength;
                if (instance_length > 0)
                {
                    for (int i = 0; i < instance_count; i++)
                    {
                        parent_id_stack.Push(parms[current_index].id);
                        parent_count_stack.Push(1);
                    }
                }
                current_index++;
            }
            else if (parms[current_index].type == HAPI_ParmType.HAPI_PARMTYPE_FOLDERLIST)
            {
                // The current parameter is a folder list which means the next parms[ current_index ].size
                // parameters will be folders belonging to this folder list. Push to the stack a new
                // folder depth, ready to eat the next few parameters belonging to the folder list's
                // selected folder.

                bool folder_list_invisible = parms[current_index].invisible;
                int  folder_count          = parms[current_index].size;
                int  first_folder_index    = current_index + 1;
                int  last_folder_index     = current_index + folder_count;

                // Generate the list of folders which will be passed to the GUILayout.Toolbar() method.
                List <int>    tab_ids             = new List <int>();
                List <string> tab_labels          = new List <string>();
                List <int>    tab_sizes           = new List <int>();
                bool          has_visible_folders = false;
                for (current_index = first_folder_index; current_index <= last_folder_index; ++current_index)
                {
                    if (parms[current_index].type != HAPI_ParmType.HAPI_PARMTYPE_FOLDER)
                    {
                        Debug.LogError("We should be iterating through folders only here!"
                                       + "\nCurrent Index: " + current_index + ", folder_count: " + folder_count);
                    }

                    // Don't add this folder if it's invisible.
                    if (parms[current_index].invisible || folder_list_invisible)
                    {
                        continue;
                    }
                    else
                    {
                        has_visible_folders = true;
                    }

                    tab_ids.Add(parms[current_index].id);
                    tab_labels.Add(parm_strings[current_index].label);
                    tab_sizes.Add(parms[current_index].size);
                }
                current_index--;                 // We decrement the current_index as we incremented one too many in the for loop.

                // If there are no folders visible in this folder list, don't even append the folder stacks.
                if (has_visible_folders)
                {
                    folder_list_count++;

                    // If myObjectControl.myFolderListSelections is smaller than our current depth it means this
                    // is the first GUI generation for this asset (no previous folder selection data) so
                    // increase the size of the selection arrays to accomodate the new depth.
                    if (myParms.prFolderListSelections.Count <= folder_list_count)
                    {
                        myParms.prFolderListSelections.Add(0);
                        myParms.prFolderListSelectionIds.Add(HoudiniConstants.HAPI_INVALID_PARM_ID);
                    }

                    int selected_folder = myParms.prFolderListSelections[folder_list_count];
                    selected_folder = Mathf.Clamp(selected_folder, 0, tab_labels.Count - 1);
                    selected_folder = GUILayout.Toolbar(selected_folder, tab_labels.ToArray());
                    myParms.prFolderListSelections[folder_list_count] = selected_folder;

                    // Push only the selected folder info to the parent stacks since for this depth and this folder
                    // list only the parameters of the selected folder need to be generated.
                    parent_id_stack.Push(tab_ids[selected_folder]);
                    parent_count_stack.Push(tab_sizes[selected_folder]);
                }
                current_index++;
            }
            else if (parms[current_index].isChildOfMultiParm)
            {
                GUILayout.BeginHorizontal();

                // Create the add / remove buttons
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("X"))
                {
                    myParms.removeMultiparmInstance(parms[current_index]);
                    changed = true;
                }
                if (GUILayout.Button("+"))
                {
                    myParms.insertMultiparmInstance(parms[current_index]);
                    changed = true;
                }
                GUILayout.EndHorizontal();

                // Create the parms within the multiparm instance
                GUILayout.BeginVertical();
                for (int i = 0; i < instance_length; i++)
                {
                    changed |= generateAssetControl(current_index, ref join_last, ref no_label_toggle_last);
                    current_index++;
                }
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
                if (instance_length > 1)
                {
                    HoudiniGUI.separator();
                }
            }
            else
            {
                // The current parameter is a simple parameter so just draw it.
                if (parms[current_index].type == HAPI_ParmType.HAPI_PARMTYPE_FOLDER)
                {
                    Debug.LogError("All folders should have been parsed in the folder list if clause!");
                }

                changed |= generateAssetControl(current_index, ref join_last, ref no_label_toggle_last);

                current_index++;
            }
        }

        if (myLastFocusedControl != GUI.GetNameOfFocusedControl())
        {
            //Debug.Log( "Changed focus from " + myLastFocusedControl + " to " + GUI.GetNameOfFocusedControl() );
            // We changed focus. Signal a build
            myLastFocusedControl = GUI.GetNameOfFocusedControl();
            myFocusChanged       = true;
            myDelayBuild         = false;
        }

        return(changed);
    }
    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);
    }
    public override void OnInspectorGUI()
    {
        if (myGeoAttributeManager == null)
        {
            return;
        }

        bool is_editable = true;

        // We can only build or do anything if we can link to our libraries.
#if !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || (UNITY_METRO && UNITY_EDITOR))
        is_editable = false;
        HoudiniGUI.help(HoudiniConstants.HAPI_UNSUPPORTED_PLATFORM_MSG, MessageType.Info);
#else
        if (!is_editable)
        {
            HoudiniGUI.help("This mesh is not editable.", MessageType.Info);
        }
#endif // !( UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || ( UNITY_METRO && UNITY_EDITOR ) )

        bool gui_enable = GUI.enabled;
        GUI.enabled = is_editable;

        myAssetInput.prShowHoudiniControls
            = HoudiniGUI.foldout("Houdini Controls", myAssetInput.prShowHoudiniControls, true);
        if (myAssetInput.prShowHoudiniControls)
        {
            if (!myAssetInput.isPrefab())
            {
                if (GUILayout.Button("Rebuild"))
                {
                    myAssetInput.buildAll();
                }

                if (GUILayout.Button("Recook"))
                {
                    myAssetInput.buildClientSide();
                }
            }
        }

        // Draw Help Pane
        myAssetInput.prShowHelp = HoudiniGUI.foldout("Asset Help", myAssetInput.prShowHelp, true);
        if (myAssetInput.prShowHelp)
        {
            drawHelpBox(myHelpText);
        }

        ///////////////////////////////////////////////////////////////////////
        // Draw Asset Settings
        // These don't affect the asset directly so they don't trigger rebuilds.

        myAssetInput.prShowAssetSettings = HoudiniGUI.foldout("Asset Settings", myAssetInput.prShowAssetSettings, true);
        if (myAssetInput.prShowAssetSettings)
        {
            // Enable Cooking Toggle
            createToggleForProperty(
                "enable_cooking", "Enable Cooking", "prEnableCooking",
                ref myUndoInfo.enableCooking, null, !HoudiniHost.isEnableCookingDefault());

            HoudiniGUI.separator();

            // Cooking Triggers Downstream Cooks Toggle
            createToggleForProperty(
                "cooking_triggers_downstream_cooks", "Cooking Triggers Downstream Cooks",
                "prCookingTriggersDownCooks", ref myUndoInfo.cookingTriggersDownCooks,
                null, !HoudiniHost.isCookingTriggersDownCooksDefault(),
                !myAssetInput.prEnableCooking, " (all cooking is disabled)");

            HoudiniGUI.separator();

            // Push Unity Transform To Houdini Engine Toggle
            createToggleForProperty(
                "push_unity_transform_to_houdini_engine", "Push Unity Transform To Houdini Engine",
                "prPushUnityTransformToHoudini", ref myUndoInfo.pushUnityTransformToHoudini,
                null, !HoudiniHost.isPushUnityTransformToHoudiniDefault());

            // Transform Change Triggers Cooks Toggle
            createToggleForProperty(
                "transform_change_triggers_cooks", "Transform Change Triggers Cooks",
                "prTransformChangeTriggersCooks", ref myUndoInfo.transformChangeTriggersCooks,
                null, !HoudiniHost.isTransformChangeTriggersCooksDefault(),
                !myAssetInput.prEnableCooking, " (all cooking is disabled)");
        }

        ///////////////////////////////////////////////////////////////////////
        // Draw Point Attributes

        myAssetInput.prShowAttributesTable = HoudiniGUI.foldout("Point Attributes", myAssetInput.prShowAttributesTable, true);
        if (myAssetInput.prShowAttributesTable)
        {
            // Draw Create Point Attributes Action Bar
            {
                string[] preset_labels = new string[] {
                    "Create Point Attribute:", "Custom", "Color", "UV", "Normal", "Bool", "Int", "Float", "String"
                };
                int[] preset_values = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };

                GUIStyle style = new GUIStyle(EditorStyles.popup);
                style.fixedHeight   = 18;
                style.margin.bottom = 6;
                int preset_selected = EditorGUILayout.IntPopup(
                    0, preset_labels, preset_values, style);

                if (preset_selected == 1)
                {
                    myGeoAttributeManager.createAttribute();
                    myAssetInput.prHasAttributeChanges = true;
                }
                else if (preset_selected > 1)
                {
                    HoudiniGeoAttribute.Preset preset = (HoudiniGeoAttribute.Preset)(preset_selected - 2);
                    myGeoAttributeManager.createAttribute(preset);
                    myAssetInput.prHasAttributeChanges = true;
                }
            }

            // Draw recook notice.
            string help_msg = "There are uncommitted attribute changes. Press 'Recook' when ready.";
            if (myAssetInput.prHasError)
            {
                help_msg += "\nError: " + myAssetInput.prErrorMsg;
            }
            if (myAssetInput.prHasAttributeChanges)
            {
                HoudiniGUI.help(help_msg, MessageType.Info);
            }
            else
            {
                HoudiniGUI.help("Ready", MessageType.Info);
            }

            HoudiniGUI.separator();

            string[] type_labels = new string[] { "bool", "int", "float", "string" };
            int[]    type_values = new int[] { 0, 1, 2, 3 };

            string[] tuple_labels = new string[] { "1", "2", "3", "4", "5" };
            int[]    tuple_values = new int[] { 1, 2, 3, 4, 5 };

            // Draw table header.
            {
                EditorGUILayout.BeginHorizontal();

                GUIStyle label_style = new GUIStyle(EditorStyles.label);
                label_style.padding.right = -5;
                label_style.margin.left   = -5;
                label_style.border.right  = -10;

                EditorGUILayout.LabelField("Name", GUILayout.MinWidth(100));
                EditorGUILayout.LabelField("Type", GUILayout.Width(50));
                EditorGUILayout.LabelField("Tuple", GUILayout.Width(50));
                EditorGUILayout.LabelField("|", GUILayout.Width(8));
                EditorGUILayout.LabelField("Min", GUILayout.Width(50));
                EditorGUILayout.LabelField("Max", GUILayout.Width(50));
                EditorGUILayout.LabelField("", GUILayout.Width(27));

                EditorGUILayout.EndHorizontal();
            }

            for (int i = 0; i < myGeoAttributeManager.prAttributes.Count; ++i)
            {
                HoudiniGeoAttribute attrib = myGeoAttributeManager.prAttributes[i];

                EditorGUILayout.BeginHorizontal();

                // Attribute Name
                string new_name = EditorGUILayout.TextField(attrib.prName, GUILayout.MinWidth(100));
                if (new_name != attrib.prName)
                {
                    attrib.prName = new_name;
                    myAssetInput.prHasAttributeChanges = true;
                }

                // Attribute Type
                HoudiniGeoAttribute.Type new_attrib_type = (HoudiniGeoAttribute.Type)EditorGUILayout.IntPopup(
                    (int)attrib.prType, type_labels, type_values, GUILayout.Width(50));
                if (new_attrib_type != attrib.prType)
                {
                    attrib.prType = new_attrib_type;
                    myAssetInput.prHasAttributeChanges = true;
                }

                // Attribute Tuple Size
                int new_tuple_size = EditorGUILayout.IntPopup(
                    attrib.prTupleSize, tuple_labels, tuple_values, GUILayout.Width(50));
                if (new_tuple_size != attrib.prTupleSize)
                {
                    attrib.prTupleSize = new_tuple_size;
                    myAssetInput.prHasAttributeChanges = true;
                }

                EditorGUILayout.LabelField("|", GUILayout.Width(8));

                // Range
                if (attrib.prType == HoudiniGeoAttribute.Type.STRING)
                {
                    EditorGUILayout.LabelField("N/A", GUILayout.MinWidth(20));
                }
                else
                {
                    if (attrib.prType == HoudiniGeoAttribute.Type.BOOL || attrib.prType == HoudiniGeoAttribute.Type.INT)
                    {
                        attrib.prIntMin =
                            EditorGUILayout.IntField("", attrib.prIntMin, GUILayout.Width(50));
                    }
                    else if (attrib.prType == HoudiniGeoAttribute.Type.FLOAT)
                    {
                        attrib.prFloatMin =
                            EditorGUILayout.FloatField("", attrib.prFloatMin, GUILayout.Width(50));
                    }

                    if (attrib.prType == HoudiniGeoAttribute.Type.BOOL || attrib.prType == HoudiniGeoAttribute.Type.INT)
                    {
                        attrib.prIntMax =
                            EditorGUILayout.IntField("", attrib.prIntMax, GUILayout.Width(50));
                    }
                    else if (attrib.prType == HoudiniGeoAttribute.Type.FLOAT)
                    {
                        attrib.prFloatMax =
                            EditorGUILayout.FloatField("", attrib.prFloatMax, GUILayout.Width(50));
                    }
                }

                EditorGUILayout.LabelField("|", GUILayout.Width(8));

                GUIStyle label_style = new GUIStyle(EditorStyles.label);
                label_style.fontStyle = FontStyle.Bold;
                if (GUILayout.Button("X", label_style, GUILayout.Width(15), GUILayout.Height(15)))
                {
                    myGeoAttributeManager.deleteAttribute(attrib.prName);
                    myAssetInput.prHasAttributeChanges = true;
                }

                EditorGUILayout.EndHorizontal();
            }

            {
                EditorGUILayout.BeginHorizontal();
                GUIStyle label_style = new GUIStyle(EditorStyles.label);
                label_style.fontStyle     = FontStyle.Normal;
                label_style.alignment     = TextAnchor.MiddleRight;
                label_style.padding.left  = 0;
                label_style.margin.left   = 0;
                label_style.padding.right = 0;
                label_style.margin.right  = 0;
                EditorGUILayout.LabelField("Delete Attribute", label_style, GUILayout.MinWidth(40));

                label_style.fontStyle     = FontStyle.Bold;
                label_style.padding.left  = 0;
                label_style.margin.left   = 6;
                label_style.padding.right = 5;
                label_style.margin.right  = 5;
                EditorGUILayout.LabelField("↲", label_style, GUILayout.Width(10));

                EditorGUILayout.EndHorizontal();
            }
        }         // Show Attributes Table

        GUI.enabled = gui_enable;
    }
Beispiel #9
0
    private static void generateAdvancedSettings()
    {
        if (!myEnableAdvancedSettings)
        {
            if (HoudiniGUI.button(
                    "allow_advanced_settings", "Allow Editing of Advanced Settings"))
            {
                if (EditorUtility.DisplayDialog(
                        "Careful!",
                        "Changing these settings can cause the Houdini Engine plugin to stop working. " +
                        "Are you sure you want to edit them?",
                        "Yes", "No"))
                {
                    myEnableAdvancedSettings = true;
                }
            }
        }
        else
        {
            if (HoudiniGUI.button(
                    "disallow_advanced_settings", "Disallow Editing of Advanced Settings"))
            {
                myEnableAdvancedSettings = false;
            }
        }

        HoudiniGUI.separator();

        bool gui_enabled = GUI.enabled;

        GUI.enabled = myEnableAdvancedSettings;

        // Collision Group Name
        {
            string value   = HoudiniHost.prCollisionGroupName;
            bool   changed = HoudiniGUI.stringField(
                "collision_group_name", "Colli. Grp.", ref value,
                myUndoInfo, ref myUndoInfo.collisionGroupName);
            if (changed)
            {
                HoudiniHost.prCollisionGroupName = value;
            }
        }

        // Rendered Collision Group Name
        {
            string value   = HoudiniHost.prRenderedCollisionGroupName;
            bool   changed = HoudiniGUI.stringField(
                "rendered_collision_group_name",
                "Rendered Colli. Grp.", ref value, myUndoInfo,
                ref myUndoInfo.renderedCollisionGroupName);
            if (changed)
            {
                HoudiniHost.prRenderedCollisionGroupName = value;
            }
        }

        HoudiniGUI.separator();

        // Unity Material Attrib Name
        {
            string value   = HoudiniHost.prUnityMaterialAttribName;
            bool   changed = HoudiniGUI.stringField(
                "unity_material_attrib_name",
                "Unity Mat. Attrib.",
                ref value, myUndoInfo,
                ref myUndoInfo.unityMaterialAttribName);
            if (changed)
            {
                HoudiniHost.prUnityMaterialAttribName = value;
            }
        }

        // Unity Sub Material Name Attrib Name
        {
            string value   = HoudiniHost.prUnitySubMaterialNameAttribName;
            bool   changed = HoudiniGUI.stringField(
                "unity_sub_material_name_attrib_name",
                "Unity SubMat. Name Attrib.",
                ref value, myUndoInfo,
                ref myUndoInfo.unitySubMaterialNameAttribName);
            if (changed)
            {
                HoudiniHost.prUnitySubMaterialNameAttribName = value;
            }
        }

        // Unity Sub Material Index Attrib Name
        {
            string value   = HoudiniHost.prUnitySubMaterialIndexAttribName;
            bool   changed = HoudiniGUI.stringField(
                "unity_sub_material_index_attrib_name",
                "Unity SubMat. Index Attrib.",
                ref value, myUndoInfo,
                ref myUndoInfo.unitySubMaterialIndexAttribName);
            if (changed)
            {
                HoudiniHost.prUnitySubMaterialIndexAttribName = value;
            }
        }

        HoudiniGUI.separator();

        // Unity Tag Attrib Name
        {
            string value   = HoudiniHost.prUnityTagAttribName;
            bool   changed = HoudiniGUI.stringField(
                "unity_tag_attrib_name", "Unity Tag Attrib.",
                ref value, myUndoInfo,
                ref myUndoInfo.unityTagAttribName);
            if (changed)
            {
                HoudiniHost.prUnityTagAttribName = value;
            }
        }

        GUI.enabled = gui_enabled;
    }
Beispiel #10
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();
            }
        }
    }
Beispiel #11
0
    private static void generateCookingSettings()
    {
        // Enable Cooking
        {
            bool value   = HoudiniHost.prEnableCooking;
            bool changed = HoudiniGUI.toggle(
                "enable_cooking", "Enable Cooking", ref value,
                myUndoInfo, ref myUndoInfo.enableCooking);
            if (changed)
            {
                HoudiniHost.prEnableCooking = value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Cooking Triggers Downstream Cooks
        {
            bool value   = HoudiniHost.prCookingTriggersDownCooks;
            bool changed = HoudiniGUI.toggle(
                "cooking_triggers_downstream_cooks",
                "Cooking Triggers Downstream Cooks",
                ref value, myUndoInfo,
                ref myUndoInfo.cookingTriggersDownCooks);
            if (changed)
            {
                HoudiniHost.prCookingTriggersDownCooks = value;
                HoudiniHost.repaint();
            }
        }

        // Playmode Per-Frame Cooking
        {
            bool value   = HoudiniHost.prPlaymodePerFrameCooking;
            bool changed = HoudiniGUI.toggle(
                "playmode_per_frame_cooking",
                "Playmode Per-Frame Cooking",
                ref value, myUndoInfo,
                ref myUndoInfo.playmodePerFrameCooking);
            if (changed)
            {
                HoudiniHost.prPlaymodePerFrameCooking = value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Push Unity Transform To Houdini Engine
        {
            bool value   = HoudiniHost.prPushUnityTransformToHoudini;
            bool changed = HoudiniGUI.toggle(
                "push_unity_transform_to_houdini",
                "Push Unity Transform to Houdini Engine",
                ref value, myUndoInfo,
                ref myUndoInfo.pushUnityTransformToHoudini);
            if (changed)
            {
                HoudiniHost.prPushUnityTransformToHoudini = value;
                HoudiniHost.repaint();
            }
        }

        // Transform Change Triggers Cooks
        {
            bool value   = HoudiniHost.prTransformChangeTriggersCooks;
            bool changed = HoudiniGUI.toggle(
                "transform_change_triggers_cooks",
                "Transform Change Triggers Cooks",
                ref value, myUndoInfo,
                ref myUndoInfo.transformChangeTriggersCooks);
            if (changed)
            {
                HoudiniHost.prTransformChangeTriggersCooks = value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Import Templated Geos
        {
            bool value   = HoudiniHost.prImportTemplatedGeos;
            bool changed = HoudiniGUI.toggle(
                "import_templated_geos",
                "Import Templated Geos",
                ref value, myUndoInfo,
                ref myUndoInfo.importTemplatedGeos);
            if (changed)
            {
                HoudiniHost.prImportTemplatedGeos = value;
                HoudiniHost.repaint();
            }
        }

        HoudiniGUI.separator();

        // Split Geos by Group
        {
            bool value   = HoudiniHost.prSplitGeosByGroup;
            bool changed = HoudiniGUI.toggle(
                "split_geos_by_group",
                "Split Geos by Group",
                ref value, myUndoInfo,
                ref myUndoInfo.splitGeosByGroup);
            if (changed)
            {
                HoudiniHost.prSplitGeosByGroup = value;
                HoudiniHost.repaint();

                EditorUtility.DisplayDialog(
                    "Rebuild Required",
                    "This change will take affect only after a full asset rebuild.",
                    "Ok");
            }
        }

        // Split Points by Vertex Attributes
        {
            bool value   = HoudiniHost.prSplitPointsByVertexAttributes;
            bool changed = HoudiniGUI.toggle(
                "split_points_by_vertex_attributes",
                "Split Points by Vertex Attributes",
                ref value, myUndoInfo,
                ref myUndoInfo.splitGeosByGroup);
            if (changed)
            {
                HoudiniHost.prSplitPointsByVertexAttributes = value;
                HoudiniHost.repaint();

                EditorUtility.DisplayDialog(
                    "Rebuild Required",
                    "This change will take affect only after a full asset rebuild.",
                    "Ok");
            }
        }
    }
    private void generateCookingSettings()
    {
        // Enable Cooking Toggle
        createToggleForProperty(
            "enable_cooking", "Enable Cooking", "prEnableCooking",
            ref myUndoInfo.enableCooking, null, !HoudiniHost.isEnableCookingDefault());

        HoudiniGUI.separator();

        // Cooking Triggers Downstream Cooks Toggle
        createToggleForProperty(
            "cooking_triggers_downstream_cooks", "Cooking Triggers Downstream Cooks",
            "prCookingTriggersDownCooks", ref myUndoInfo.cookingTriggersDownCooks,
            null, !HoudiniHost.isCookingTriggersDownCooksDefault(),
            !myAsset.prEnableCooking, " (all cooking is disabled)");

        // Playmode Per-Frame Cooking Toggle
        createToggleForProperty(
            "playmode_per_frame_cooking", "Playmode Per-Frame Cooking",
            "prPlaymodePerFrameCooking", ref myUndoInfo.playmodePerFrameCooking,
            null, !HoudiniHost.isPlaymodePerFrameCookingDefault(),
            !myAsset.prEnableCooking, " (all cooking is disabled)");

        HoudiniGUI.separator();

        // Push Unity Transform To Houdini Engine Toggle
        createToggleForProperty(
            "push_unity_transform_to_houdini_engine", "Push Unity Transform To Houdini Engine",
            "prPushUnityTransformToHoudini", ref myUndoInfo.pushUnityTransformToHoudini,
            null, !HoudiniHost.isPushUnityTransformToHoudiniDefault());

        // Transform Change Triggers Cooks Toggle
        createToggleForProperty(
            "transform_change_triggers_cooks", "Transform Change Triggers Cooks",
            "prTransformChangeTriggersCooks", ref myUndoInfo.transformChangeTriggersCooks,
            null, !HoudiniHost.isTransformChangeTriggersCooksDefault(),
            !myAsset.prEnableCooking, " (all cooking is disabled)");

        HoudiniGUI.separator();

        // Import Templated Geos Toggle
        createToggleForProperty(
            "import_templated_geos", "Import Templated Geos", "prImportTemplatedGeos",
            ref myUndoInfo.importTemplatedGeos, null, !HoudiniHost.isImportTemplatedGeosDefault(),
            !myAsset.prEnableCooking, " (all cooking is disabled)");

        HoudiniGUI.separator();

        // Split Geos by Group Toggle
        {
            createToggleForProperty(
                "split_geos_by_group_override", "Override Split Geos by Group", "prSplitGeosByGroupOverride",
                ref myUndoInfo.splitGeosByGroupOverride, null);
            createToggleForProperty(
                "split_geos_by_group", "Split Geos by Group", "prSplitGeosByGroup",
                ref myUndoInfo.splitGeosByGroup, () => EditorUtility.DisplayDialog(
                    "Rebuild Required",
                    "This change will take affect only after a full asset rebuild.",
                    "Ok"), false,
                !myAsset.prSplitGeosByGroupOverride, " (check the override checkbox to enable)");
        }

        HoudiniGUI.separator();

        // Omit Part Name Enumeration
        createToggleForProperty(
            "omit_part_name_enumeration", "Omit Part Name Enumeration",
            "prOmitPartNameEnumeration", ref myUndoInfo.omitPartNameEnumeration,
            null);
    }
    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;
    }
Beispiel #14
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;
			}
		}
	}