Esempio n. 1
0
    private static void generateCurveSettings()
    {
        // Curve Primitive Type Default
        {
            int      value   = HoudiniHost.prCurvePrimitiveTypeDefault;
            string[] labels  = { "Polygon", "NURBS", "Bezier" };
            int[]    values  = { 0, 1, 2 };
            bool     changed = HoudiniGUI.dropdown(
                "curve_primitive_type_default", "Initial Type",
                ref value, labels, values, myUndoInfo,
                ref myUndoInfo.curvePrimitiveTypeDefault);
            if (changed)
            {
                HoudiniHost.prCurvePrimitiveTypeDefault = value;
            }
        }

        // Curve Method Default
        {
            int      value   = HoudiniHost.prCurveMethodDefault;
            string[] labels  = { "CVs", "Breakpoints", "Freehand" };
            int[]    values  = { 0, 1, 2 };
            bool     changed = HoudiniGUI.dropdown(
                "curve_method_default", "Initial Method",
                ref value, labels, values, myUndoInfo,
                ref myUndoInfo.curveMethodDefault);
            if (changed)
            {
                HoudiniHost.prCurveMethodDefault = value;
            }
        }
    }
Esempio n. 2
0
    public override void OnInspectorGUI()
    {
        if (myCurve == null)
        {
            return;
        }

        bool is_editable = myCurve.prEditable && HoudiniHost.isInstallationOk();

        // 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 (!myCurve.prEditable)
        {
            HoudiniGUI.help("This curve is not editable.", MessageType.Info);
        }
        else if (!HoudiniHost.isInstallationOk())
        {
            HoudiniGUI.help(HoudiniHost.getMissingEngineInstallHelpString(), MessageType.Info);
        }
#endif // !( UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || ( UNITY_METRO && UNITY_EDITOR ) )

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

        Object target = (Object)myTarget;
        if (HoudiniGUI.objectField("target", "Target", ref target, typeof(GameObject)))
        {
            myTarget = (GameObject)target;
        }

        GUI.enabled = gui_enable;
    }
    protected void drawCookLog()
    {
        if (HoudiniGUI.button("get_cook_log", "Get Cook Log"))
        {
            myAsset.buildClientSide();
            myLastCookLog = HoudiniHost.getStatusString(
                HAPI_StatusType.HAPI_STATUS_COOK_RESULT,
                HAPI_StatusVerbosity.HAPI_STATUSVERBOSITY_MESSAGES);
        }

        float width = (float)Screen.width - 60;

        myCookLogScrollPosition = EditorGUILayout.BeginScrollView(
            myCookLogScrollPosition, GUILayout.Height(200));

        GUIStyle sel_label = new GUIStyle(GUI.skin.label);

        sel_label.stretchWidth = true;
        sel_label.wordWrap     = true;

        float height = sel_label.CalcHeight(
            new GUIContent(myLastCookLog), width);

        EditorGUILayout.SelectableLabel(
            myLastCookLog, sel_label, GUILayout.Width(width),
            GUILayout.Height(height));

        EditorGUILayout.EndScrollView();
    }
Esempio n. 4
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. 5
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;
	}
    public override void OnInspectorGUI()
    {
        HoudiniGUI.help("Values here are for debugging only and should not be modified directly.", MessageType.Info);

        bool gui_enabled = GUI.enabled;

        GUI.enabled = false;
        DrawDefaultInspector();
        GUI.enabled = gui_enabled;
    }
Esempio n. 7
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. 8
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();
        }
    }
 private void generatePaintToolGUI()
 {
     foreach (HoudiniGeoControl geo_control in myAssetOTL.prEditPaintGeos)
     {
         if (HoudiniGUI.button(geo_control.prGeoName, geo_control.prGeoName))
         {
             myAssetOTL.prActiveEditPaintGeo = geo_control;
             myGeoAttributeManager           = geo_control.prGeoAttributeManager;
             myGeoAttributeManagerGUI        = new HoudiniGeoAttributeManagerGUI(myGeoAttributeManager);
         }
     }
 }
    protected void createToggleForProperty(
        string name, string label, string property_name,
        ref bool undo_info_value, valueChangedFunc func,
        bool global_overwrite, bool local_overwrite,
        string local_overwrite_message)
    {
        bool gui_enabled = GUI.enabled;

        try
        {
            PropertyInfo property = typeof(HoudiniAsset).GetProperty(property_name);
            if (property == null)
            {
                throw new HoudiniErrorInvalidArgument(property_name + " is not a valid property of HAPI_Asset!");
            }
            if (property.PropertyType != typeof(bool))
            {
                throw new HoudiniErrorInvalidArgument(property_name + " is not a boolean!");
            }

            GUI.enabled = !global_overwrite && !local_overwrite && GUI.enabled;

            if (global_overwrite)
            {
                label += " (overwritted by global setting)";
            }
            else if (local_overwrite)
            {
                label += local_overwrite_message;
            }

            bool value   = ( bool )property.GetValue(myAsset, null);
            bool is_bold = myParentPrefabAsset && ( bool )property.GetValue(myParentPrefabAsset, null) != value;
            bool changed = HoudiniGUI.toggle(name, label, is_bold, ref value, myUndoInfo, ref undo_info_value);

            if (changed)
            {
                property.SetValue(myAsset, value, null);

                if (func != null)
                {
                    func();
                }
            }
        }
        catch (System.Exception error)
        {
            Debug.LogError(
                "Failed to create toggle for: " + label + "\n" +
                error.ToString() + "\nSource: " + error.Source);
        }
        GUI.enabled = gui_enabled;
    }
Esempio n. 11
0
    protected bool setTransformInput(int index)
    {
        if (myAsset.prUpStreamTransformObjects == null || myAsset.prUpStreamTransformObjects.Count <= 0)
        {
            return(false);
        }

        bool       join_last            = false;
        bool       no_label_toggle_last = true;
        GameObject temp_obj             = null;

        HoudiniGUIParm trans_input = new HoudiniGUIParm("trans_input_" + index, myAsset.prTransInputNames[index]);
        Object         obj         = (Object)myAsset.prUpStreamTransformObjects[index];
        bool           changed     = HoudiniGUI.objectField(ref trans_input, ref obj, typeof(GameObject),
                                                            ref join_last, ref no_label_toggle_last, null, ref temp_obj);

        if (changed)
        {
            if (!obj)
            {
                myAsset.prUpStreamTransformObjects[index] = null;
                myAsset.removeTransformInput(index);
            }
            else
            {
                GameObject game_obj = (GameObject)obj;
                myAsset.prUpStreamTransformObjects[index] = game_obj;
                HoudiniAsset input_asset = game_obj.GetComponent <HoudiniAsset>();
                if (input_asset)
                {
                    myAsset.addAssetAsTransformInput(input_asset, index);
                }
                else
                {
                    myAsset.removeTransformInput(index);
                }
                myAsset.buildClientSide();
            }
        }

        return(changed);
    }
Esempio n. 12
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();
    }
Esempio n. 13
0
    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. 14
0
    public override void OnInspectorGUI()
    {
        myPartControl.prShowDisplayOptions =
            HoudiniGUI.foldout("Display Options", myPartControl.prShowDisplayOptions, true);
        if (myPartControl.prShowDisplayOptions)
        {
            {
                if (HoudiniGUI.button("print_attribute_names", "Print Attribute Names"))
                {
                    HoudiniAssetUtility.printAllAttributeNames(
                        myPartControl.prAssetId, myPartControl.prObjectId,
                        myPartControl.prGeoId, myPartControl.prPartId);
                }

                if (HoudiniGUI.button("print_group_info", "Print Group Info"))
                {
                    HoudiniAssetUtility.printAllGroups(
                        myPartControl.prAssetId, myPartControl.prObjectId,
                        myPartControl.prGeoId, myPartControl.prPartId);
                }
            }

            {             // Show Houdini Point Numbers
                bool value      = myPartControl.prShowPointNumbers;
                bool undo_value = false;
                bool changed    = HoudiniGUI.toggle(
                    "show_point_numbers", "Show Houdini Point Numbers", ref value,
                    null, ref undo_value);
                myPartControl.prShowPointNumbers = value;
                if (changed)
                {
                    EditorUtility.SetDirty(myPartControl);
                }
            }
        }

        myPartControl.prShowIntermediateResultControls =
            HoudiniGUI.foldout("Intermediate Results", myPartControl.prShowIntermediateResultControls, true);
        if (myPartControl.prShowIntermediateResultControls)
        {
            bool gui_enabled = GUI.enabled;
            if (myPartControl.prGeoType != HAPI_GeoType.HAPI_GEOTYPE_INTERMEDIATE)
            {
                HoudiniGUI.help(
                    "Only specially marked intermediate results geometries can be edited.",
                    MessageType.Info);
                GUI.enabled = false;
            }

            if (GUILayout.Button("Update Intermediate Result"))
            {
                MeshFilter         mesh_filter  = myPartControl.gameObject.GetComponent <MeshFilter>();
                Mesh               shared_mesh  = mesh_filter.sharedMesh;
                HoudiniPartControl part_control = myPartControl.gameObject.GetComponent <HoudiniPartControl>();

                HoudiniAssetUtility.setMesh(
                    myPartControl.prAsset.prAssetId,
                    myPartControl.prObjectId,
                    myPartControl.prGeoId,
                    ref shared_mesh,
                    part_control,
                    null);

                myPartControl.prAsset.buildClientSide();
            }

            if (GUILayout.Button("Clear Edits"))
            {
                HoudiniHost.revertGeo(
                    myPartControl.prAsset.prAssetId,
                    myPartControl.prObjectId,
                    myPartControl.prGeoId);

                myPartControl.prAsset.buildClientSide();
            }

            GUI.enabled = gui_enabled;
        }

        myPartControl.prShowInfo =
            HoudiniGUI.foldout("Info", myPartControl.prShowInfo, true);
        if (myPartControl.prShowInfo)
        {
            HoudiniGUI.help("Values here are for debugging only and should not be modified directly.", MessageType.Info);
            bool gui_enabled = GUI.enabled;
            GUI.enabled = false;
            DrawDefaultInspector();
            GUI.enabled = gui_enabled;
        }
    }
Esempio n. 15
0
    public override void OnInspectorGUI()
    {
        try
        {
            myDelayBuild   = false;
            myParmChanges  = false;
            myFocusChanged = false;

            Event current_event  = Event.current;
            bool  commit_changes = false;
            if (current_event.isKey && current_event.type == EventType.KeyUp && current_event.keyCode == KeyCode.Return)
            {
                commit_changes = true;
            }
            else if (
                current_event.type == EventType.ValidateCommand &&
                current_event.commandName == "UndoRedoPerformed")
            {
                performUndo();
            }

            ///////////////////////////////////////////////////////////////////////
            // Draw Asset Controls

            bool is_editable = myParms.prEditable && HoudiniHost.isInstallationOk();

            // We can only build or do anything if we can link to our libraries.
#if !( HAPI_ENABLE_RUNTIME )
            is_editable = false;
            HoudiniGUI.help(HoudiniConstants.HAPI_UNSUPPORTED_PLATFORM_MSG, MessageType.Info);
#else
            if (!myParms.prEditable)
            {
                HoudiniGUI.help("The parameters on this node are readonly.", MessageType.Info);
            }
            else if (!HoudiniHost.isInstallationOk())
            {
                HoudiniGUI.help(HoudiniHost.getMissingEngineInstallHelpString(), MessageType.Info);
            }
#endif // !( HAPI_ENABLE_RUNTIME )

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

            myParmChanges |= generateAssetControls();

            GUI.enabled = gui_enable;

            ///////////////////////////////////////////////////////////////////////
            // Apply Changes

            // Only record undo info object if parameters are not being changed
            // due to an undo/redo event.
            bool record_undo = current_event.commandName != "UndoRedoPerformed";
            applyChanges(commit_changes, record_undo);
        }
        catch (HoudiniErrorIgnorable) {}
        catch (HoudiniError error)
        {
            Debug.LogError(error.ToString() + "\nSource: " + error.Source);
        }
        catch (System.Exception error)
        {
            Debug.LogError(error.ToString() + "\nSource: " + error.Source);
        }
    }
    public override void OnInspectorGUI()
    {
        bool gui_enable = GUI.enabled;

        // 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))
        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 ) )

        try
        {
            myDelayBuild  = false;
            myParmChanges = false;

            ///////////////////////////////////////////////////////////////////////
            // Draw Game Object Controls

            if (HoudiniHost.isAssetValid(myAsset.prAssetId, myAsset.prAssetValidationId) &&
                (myAsset.prTransformInputCount > 0 || myAsset.prGeoInputCount > 0) &&
                myAsset.prAssetSubType != HAPI_AssetSubType.HAPI_ASSETSUBTYPE_CURVE &&
                !myAsset.isPrefab())
            {
                myAsset.prShowInputControls = HoudiniGUI.foldout("Inputs", myAsset.prShowInputControls, true);

                if (myAsset.prShowInputControls)
                {
                    if (myAsset.prHAPIAssetType == HAPI_AssetType.HAPI_ASSETTYPE_OBJ)
                    {
                        for (int ii = 0; ii < myAsset.prTransformInputCount; ++ii)
                        {
                            myParmChanges |= setTransformInput(ii);
                        }
                    }

                    if (myAsset.prUpStreamGeoObjects == null || myAsset.prUpStreamGeoAssets == null ||
                        myAsset.prUpStreamGeoObjects.Count <= 0 || myAsset.prUpStreamGeoAssets.Count <= 0)
                    {
                        return;
                    }

                    for (int input_index = 0; input_index < myAsset.prGeoInputCount; ++input_index)
                    {
                        bool join_last            = false;
                        bool no_label_toggle_last = true;

                        HoudiniGUIParm geo_input = new HoudiniGUIParm(
                            "geo_input_" + input_index, myAsset.prGeoInputNames[input_index]);
                        Object obj = (Object)myAsset.prUpStreamGeoObjects[input_index];
                        myParmChanges |= HoudiniGUI.objectField(
                            ref geo_input, ref obj, typeof(GameObject), ref join_last, ref no_label_toggle_last);

                        if (myParmChanges || !myAsset.isGeoInputValid(input_index))
                        {
                            if (!obj)
                            {
                                myAsset.removeGeoInput(input_index);
                                myAsset.buildClientSide();
                            }
                            else
                            {
                                GameObject new_obj = (GameObject)obj;
                                myAsset.prUpStreamGeoObjects[input_index] = new_obj;

                                // Select the asset component (if it exists).
                                HoudiniAsset asset = new_obj.GetComponent <HoudiniAsset>();

                                // If we're selecting a specific object to input than try and
                                // get the object id. Note that by getting the HAPI_ObjectControl
                                // component we also cover the geo and part controls because
                                // they all inherit from HAPI_ObjectControl. The user can therefore
                                // drag any gameObject under the asset into another asset's
                                // input and have it all work.
                                int object_index = 0;
                                HoudiniObjectControl obj_control = new_obj.GetComponent <HoudiniObjectControl>();
                                if (obj_control)
                                {
                                    object_index = obj_control.prObjectId;
                                    asset        = obj_control.prAsset;
                                }

                                if (asset == null)
                                {
                                    myAsset.addGeoAsGeoInput(new_obj, input_index);
                                    myAsset.buildClientSide();
                                }
                                else if (myAsset.prUpStreamGeoAssets[input_index] != asset)
                                {
                                    if (myAsset == asset)
                                    {
                                        Debug.LogError("Can't connect an asset to itself!");
                                    }
                                    else
                                    {
                                        myAsset.addAssetAsGeoInput(asset, object_index, input_index);
                                        myAsset.buildClientSide();
                                    }
                                }
                            }
                        }
                    }     // for
                }         // if
            }             // if

            // Draw Cook Log Pane
            myAsset.prShowCookLog = HoudiniGUI.foldout("Asset Cook Log", myAsset.prShowCookLog, true);
            if (myAsset.prShowCookLog)
            {
                drawCookLog();
            }
        }
        catch (HoudiniError e)
        {
            Debug.LogError(e.ToString());
        }

        GUI.enabled = gui_enable;
    }
Esempio n. 17
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();
        }
    }
Esempio n. 18
0
    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 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;
    }
Esempio n. 20
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. 21
0
    public override void OnInspectorGUI()
    {
        bool gui_enable = GUI.enabled;

        // We can only build or do anything if we can link to our libraries.
#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 )

        try
        {
            myDelayBuild  = false;
            myParmChanges = false;

            ///////////////////////////////////////////////////////////////////////
            // Draw License/Logo Thingy
#if ( HAPI_ENABLE_RUNTIME )
            drawLicenseLogo();
#endif

            ///////////////////////////////////////////////////////////////////////
            // Draw Game Object Controls

            if (HoudiniHost.isNodeValid(myAsset.prAssetId, myAsset.prNodeInfo.uniqueHoudiniNodeId) &&
                (myAsset.prTransformInputCount > 0 || myAsset.prGeoInputCount > 0) &&
                myAsset.prAssetType != HoudiniAsset.AssetType.TYPE_CURVE)
            {
                myAsset.prShowInputControls = HoudiniGUI.foldout("Inputs", myAsset.prShowInputControls, true);

                if (myAsset.prShowInputControls)
                {
                    if (myAsset.prNodeInfo.type == HAPI_NodeType.HAPI_NODETYPE_OBJ)
                    {
                        for (int ii = 0; ii < myAsset.prTransformInputCount; ++ii)
                        {
                            myParmChanges |= setTransformInput(ii);
                        }
                    }

                    if (myAsset.prUpStreamGeoObjects == null || myAsset.prUpStreamGeoAssets == null ||
                        myAsset.prUpStreamGeoObjects.Count <= 0 || myAsset.prUpStreamGeoAssets.Count <= 0)
                    {
                        myAsset.prGeoInputCount = 0;
                    }

                    for (int input_index = 0; input_index < myAsset.prGeoInputCount; ++input_index)
                    {
                        bool join_last            = false;
                        bool no_label_toggle_last = true;

                        GameObject     temp_obj  = null;
                        HoudiniGUIParm geo_input = new HoudiniGUIParm(
                            "geo_input_" + input_index, myAsset.prGeoInputNames[input_index]);
                        Object obj = (Object)myAsset.prUpStreamGeoObjects[input_index];
                        myParmChanges |= HoudiniGUI.objectField(
                            ref geo_input, ref obj, typeof(GameObject), ref join_last, ref no_label_toggle_last, null, ref temp_obj);

                        HoudiniGUIParm geo_input_transform_type = new HoudiniGUIParm(
                            "geo_input_transform_type_" + input_index, "Keep world transform");

                        bool transform_type      = myAsset.prGeoInputsTransformTypes[input_index] != 0;
                        bool TransformTypeUpdate = HoudiniGUI.toggle(ref geo_input_transform_type, ref transform_type);

                        bool need_build_client_side = false;
                        if (myParmChanges || !myAsset.isGeoInputValid(input_index))
                        {
                            if (!obj)
                            {
                                myAsset.removeGeoInput(input_index);
                                //myAsset.buildClientSide();
                                need_build_client_side = true;
                            }
                            else
                            {
                                GameObject new_obj = (GameObject)obj;
                                myAsset.prUpStreamGeoObjects[input_index] = new_obj;

                                // Select the asset component (if it exists).
                                HoudiniAsset asset = new_obj.GetComponent <HoudiniAsset>();

                                // If we're selecting a specific object to input than try and
                                // get the object id. Note that by getting the HAPI_ObjectControl
                                // component we also cover the geo and part controls because
                                // they all inherit from HAPI_ObjectControl. The user can therefore
                                // drag any gameObject under the asset into another asset's
                                // input and have it all work.
                                int object_index = 0;
                                HoudiniObjectControl obj_control = new_obj.GetComponent <HoudiniObjectControl>();
                                if (obj_control)
                                {
                                    object_index = obj_control.prObjectId;
                                    asset        = obj_control.prAsset;
                                }

                                if (asset == null)
                                {
                                    // Connecting a new game object
                                    myAsset.addGeoAsGeoInput(new_obj, input_index);
                                    myAsset.updateGeoInputTransformType(input_index, transform_type ? 1 : 0);
                                    need_build_client_side = true;
                                    //myAsset.buildClientSide();
                                }
                                else if (myAsset.prUpStreamGeoAssets[input_index] != asset)
                                {
                                    // Connecting a new asset
                                    if (myAsset == asset)
                                    {
                                        Debug.LogError("Can't connect an asset to itself!");
                                    }
                                    else
                                    {
                                        myAsset.addAssetAsGeoInput(asset, object_index, input_index);
                                        myAsset.updateGeoInputTransformType(input_index, transform_type ? 1 : 0);
                                        need_build_client_side = true;
                                        //myAsset.buildClientSide();
                                    }
                                }
                            }
                        }

                        if (TransformTypeUpdate)
                        {
                            myAsset.updateGeoInputTransformType(input_index, transform_type ? 1 : 0);
                            need_build_client_side = true;
                        }

                        if (need_build_client_side)
                        {
                            myAsset.buildClientSide();
                        }
                    }     // for
                }         // if
            }             // if

            // Draw Cook Log Pane
            myAsset.prShowCookLog = HoudiniGUI.foldout("Asset Cook Log", myAsset.prShowCookLog, true);
            if (myAsset.prShowCookLog)
            {
                drawCookLog();
            }
        }
        catch (HoudiniError e)
        {
            Debug.LogError(e.ToString());
        }

        GUI.enabled = gui_enable;
    }
    private void generateMaterialSettings()
    {
        if (GUILayout.Button("Re-Render"))
        {
            HoudiniAssetUtility.reApplyMaterials(myAsset);
        }

        // Material Shader Type
        {
            HAPI_ShaderType   value   = myAsset.prMaterialShaderType;
            bool              is_bold = myParentPrefabAsset && myParentPrefabAsset.prMaterialShaderType != value;
            string[]          labels  = { "OpenGL", "Houdini Mantra Renderer" };
            HAPI_ShaderType[] values  = { HAPI_ShaderType.HAPI_SHADER_OPENGL, HAPI_ShaderType.HAPI_SHADER_MANTRA };
            bool              changed = HoudiniGUI.dropdown(
                "material_renderer", "Material Renderer", ref value,
                is_bold, labels, values, myUndoInfo,
                ref myUndoInfo.materialShaderType);
            if (changed)
            {
                myAsset.prMaterialShaderType = (HAPI_ShaderType)value;
                HoudiniAssetUtility.reApplyMaterials(myAsset);
            }
        }

        // Render Resolution
        {
            bool  delay_build = false;
            int[] values      = new int[2];
            values[0] = (int)myAsset.prRenderResolution[0];
            values[1] = (int)myAsset.prRenderResolution[1];
            int[] undo_values = new int[2];
            undo_values[0] = (int)myUndoInfo.renderResolution[0];
            undo_values[1] = (int)myUndoInfo.renderResolution[1];
            HoudiniGUIParm gui_parm = new HoudiniGUIParm("render_resolution", "Render Resolution", 2);

            gui_parm.isBold =
                myParentPrefabAsset &&
                (int)myParentPrefabAsset.prRenderResolution[0] != values[0] &&
                (int)myParentPrefabAsset.prRenderResolution[1] != values[1];

            bool changed = HoudiniGUI.intField(
                ref gui_parm, ref delay_build, ref values,
                myUndoInfo, ref undo_values);
            if (changed)
            {
                Vector2 new_resolution = new Vector2((float)values[0], (float)values[1]);
                myAsset.prRenderResolution  = new_resolution;
                myUndoInfo.renderResolution = new_resolution;
            }
        }

        // Show Vertex Colours
        createToggleForProperty(
            "show_only_vertex_colours", "Show Only Vertex Colors",
            "prShowOnlyVertexColours", ref myUndoInfo.showOnlyVertexColours,
            () => HoudiniAssetUtility.reApplyMaterials(myAsset));

        // Generate Tangents
        createToggleForProperty(
            "generate_tangents", "Generate Tangents", "prGenerateTangents",
            ref myUndoInfo.generateTangents,
            () => myAssetOTL.build(
                true,                   // reload_asset
                false,                  // unload_asset_first
                false,                  // serialization_recovery_only
                true,                   // force_reconnect
                false,                  // is_duplication
                myAsset.prCookingTriggersDownCooks,
                true                    // use_delay_for_progress_bar
                ), !HoudiniHost.isGenerateTangentsDefault());
    }
Esempio n. 23
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");
            }
        }
    }
Esempio n. 24
0
    public override void OnInspectorGUI()
    {
        bool gui_enable = GUI.enabled;

        // We can only build or do anything if we can link to our libraries.
#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 )

        try
        {
            myDelayBuild  = false;
            myParmChanges = false;

            ///////////////////////////////////////////////////////////////////////
            // Draw License/Logo Thingy
#if ( HAPI_ENABLE_RUNTIME )
            drawLicenseLogo();
#endif

            ///////////////////////////////////////////////////////////////////////
            // Draw Game Object Controls

            /*if ( HoudiniHost.isNodeValid( myAsset.prAssetId, myAsset.prNodeInfo.uniqueHoudiniNodeId ) &&
             *      ( myAsset.prTransformInputCount > 0 || myAsset.prGeoInputCount > 0 ) &&
             *       myAsset.prAssetSubType != HAPI_AssetSubType.HAPI_ASSETSUBTYPE_CURVE )
             * {
             *      myAsset.prShowInputControls = HoudiniGUI.foldout( "Inputs", myAsset.prShowInputControls, true );
             *
             *      if ( myAsset.prShowInputControls )
             *      {
             *              if ( myAsset.prHAPIAssetType == HAPI_AssetType.HAPI_ASSETTYPE_OBJ )
             *                      for ( int ii = 0; ii < myAsset.prTransformInputCount; ++ii )
             *                              myParmChanges |= setTransformInput( ii );
             *
             *              if ( myAsset.prUpStreamGeoObjects == null || myAsset.prUpStreamGeoAssets == null ||
             *                       myAsset.prUpStreamGeoObjects.Count <= 0 || myAsset.prUpStreamGeoAssets.Count <= 0 )
             *                      myAsset.prGeoInputCount = 0;
             *
             *              for ( int input_index = 0; input_index < myAsset.prGeoInputCount; ++input_index )
             *              {
             *                      bool join_last = false;
             *                      bool no_label_toggle_last = true;
             *
             *                      HoudiniGUIParm geo_input = new HoudiniGUIParm(
             *                              "geo_input_" + input_index, myAsset.prGeoInputNames[ input_index ] );
             *                      Object obj = (Object) myAsset.prUpStreamGeoObjects[ input_index ];
             *                      myParmChanges |= HoudiniGUI.objectField(
             *                              ref geo_input, ref obj, typeof( GameObject ), ref join_last, ref no_label_toggle_last );
             *
             *                      if ( myParmChanges || !myAsset.isGeoInputValid( input_index ) )
             *                      {
             *                              if ( !obj )
             *                              {
             *                                      myAsset.removeGeoInput( input_index );
             *                                      myAsset.buildClientSide();
             *                              }
             *                              else
             *                              {
             *                                      GameObject new_obj = (GameObject) obj;
             *                                      myAsset.prUpStreamGeoObjects[ input_index ] = new_obj;
             *
             *                                      // Select the asset component (if it exists).
             *                                      HoudiniAsset asset = new_obj.GetComponent< HoudiniAsset >();
             *
             *                                      // If we're selecting a specific object to input than try and
             *                                      // get the object id. Note that by getting the HAPI_ObjectControl
             *                                      // component we also cover the geo and part controls because
             *                                      // they all inherit from HAPI_ObjectControl. The user can therefore
             *                                      // drag any gameObject under the asset into another asset's
             *                                      // input and have it all work.
             *                                      int object_index = 0;
             *                                      HoudiniObjectControl obj_control = new_obj.GetComponent< HoudiniObjectControl >();
             *                                      if ( obj_control )
             *                                      {
             *                                              object_index = obj_control.prObjectId;
             *                                              asset = obj_control.prAsset;
             *                                      }
             *
             *                                      if ( asset == null )
             *                                      {
             *                                              myAsset.addGeoAsGeoInput( new_obj, input_index );
             *                                              myAsset.buildClientSide();
             *                                      }
             *                                      else if ( myAsset.prUpStreamGeoAssets[ input_index ] != asset )
             *                                      {
             *                                              if ( myAsset == asset )
             *                                                      Debug.LogError( "Can't connect an asset to itself!" );
             *                                              else
             *                                              {
             *                                                      myAsset.addAssetAsGeoInput( asset, object_index, input_index );
             *                                                      myAsset.buildClientSide();
             *                                              }
             *                                      }
             *                              }
             *                      }
             *              } // for
             *      } // if
             * } // if
             */

            // Draw Cook Log Pane
            myAsset.prShowCookLog = HoudiniGUI.foldout("Asset Cook Log", myAsset.prShowCookLog, true);
            if (myAsset.prShowCookLog)
            {
                drawCookLog();
            }
        }
        catch (HoudiniError e)
        {
            Debug.LogError(e.ToString());
        }

        GUI.enabled = gui_enable;
    }
    public override void OnInspectorGUI()
    {
        if (myAssetMerger == null)
        {
            return;
        }

        bool is_editable = true;

        // We can only build or do anything if we can link to our libraries.
#if !( HAPI_ENABLE_RUNTIME )
        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 // !( HAPI_ENABLE_RUNTIME )

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

        myAssetMerger.prShowInputSelection =
            HoudiniGUI.foldout("Houdini Input Selection", myAssetMerger.prShowInputSelection, true);
        if (myAssetMerger.prShowInputSelection)
        {
            bool changed = false;

            Object     input_object = myAssetMerger.prInputObject as Object;
            GameObject temp_obj     = null;
            HoudiniGUI.objectField(
                "input_object", "Input Object", ref input_object,
                typeof(GameObject), null, ref temp_obj);
            myAssetMerger.prInputObject = input_object as GameObject;

            bool           input_layer_enable      = myAssetMerger.prUseLayerMask;
            HoudiniGUIParm input_layer_enable_parm = new HoudiniGUIParm("input_layer_enable", "");
            input_layer_enable_parm.joinNext  = true;
            input_layer_enable_parm.labelNone = true;
            changed = HoudiniGUI.toggle(ref input_layer_enable_parm, ref input_layer_enable);
            if (changed)
            {
                myAssetMerger.prUseLayerMask = input_layer_enable;
            }

            LayerMask      input_layer      = myAssetMerger.prLayerMask;
            HoudiniGUIParm input_layer_parm = new HoudiniGUIParm("input_layer", "Layer");
            input_layer_parm.disabled = !input_layer_enable;
            bool join_last            = true;
            bool no_label_toggle_last = true;
            changed = HoudiniGUI.layerField(ref input_layer_parm, ref input_layer, ref join_last, ref no_label_toggle_last);
            if (changed)
            {
                myAssetMerger.prLayerMask = input_layer;
            }

            bool           input_tag_enable      = myAssetMerger.prUseTag;
            HoudiniGUIParm input_tag_enable_parm = new HoudiniGUIParm("input_tag_enable", "");
            input_tag_enable_parm.joinNext  = true;
            input_tag_enable_parm.labelNone = true;
            changed = HoudiniGUI.toggle(ref input_layer_enable_parm, ref input_tag_enable);
            if (changed)
            {
                myAssetMerger.prUseTag = input_tag_enable;
            }

            string         input_tag      = myAssetMerger.prTag;
            HoudiniGUIParm input_tag_parm = new HoudiniGUIParm("input_tag", "Tag");
            input_tag_parm.disabled = !input_tag_enable;
            join_last            = true;
            no_label_toggle_last = true;
            changed = HoudiniGUI.tagField(ref input_tag_parm, ref input_tag, ref join_last, ref no_label_toggle_last);
            if (changed)
            {
                myAssetMerger.prTag = input_tag;
            }
        }

        myAssetMerger.prShowHoudiniControls =
            HoudiniGUI.foldout("Houdini Controls", myAssetMerger.prShowHoudiniControls, true);
        if (myAssetMerger.prShowHoudiniControls)
        {
            if (GUILayout.Button("Recook"))
            {
                myAssetMerger.buildClientSide();
            }
        }

        GUI.enabled = gui_enable;
    }
Esempio n. 26
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        bool gui_enable = GUI.enabled;

        // We can only build or do anything if we can link to our libraries.
#if !( HAPI_ENABLE_RUNTIME )
        GUI.enabled = false;
#else
        if (!HoudiniHost.isInstallationOk())
        {
            GUI.enabled = false;
        }
#endif // !( HAPI_ENABLE_RUNTIME )

        ///////////////////////////////////////////////////////////////////////
        // Draw Game Object Controls


        myAsset.prShowHoudiniControls
            = HoudiniGUI.foldout("Houdini Controls", myAsset.prShowHoudiniControls, true);
        if (myAsset.prShowHoudiniControls)
        {
            if (GUILayout.Button("Rebuild"))
            {
                myGeoAttributeManagerGUI = null;
                myAsset.buildAll();
            }

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

            if (GUILayout.Button("Bake"))
            {
                myAsset.bakeAsset();
            }
        }

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

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

        myAsset.prShowAssetSettings = HoudiniGUI.foldout("Asset Settings", myAsset.prShowAssetSettings, true);
        if (myAsset.prShowAssetSettings)
        {
            generateAssetSettings();
        }

        ///////////////////////////////////////////////////////////////////////
        // Draw Baking Controls

        myAsset.prShowBakeOptions = HoudiniGUI.foldout("Bake Animations", myAssetOTL.prShowBakeOptions, true);
        if (myAsset.prShowBakeOptions)
        {
            generateAssetBakeControls();
        }

        GUI.enabled = gui_enable;
    }
Esempio n. 27
0
    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);
    }
Esempio n. 28
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;
    }
Esempio n. 29
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;
    }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        bool gui_enable = GUI.enabled;

        // 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))
        GUI.enabled = false;
#else
        if (!HoudiniHost.isInstallationOk())
        {
            GUI.enabled = false;
        }
#endif // !( UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || ( UNITY_METRO && UNITY_EDITOR ) )

        if (myAssetOTL.isPrefabInstance())
        {
            myParentPrefabAsset = myAsset.getParentPrefabAsset();
        }

        ///////////////////////////////////////////////////////////////////////
        // Draw Game Object Controls


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

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

                if (GUILayout.Button("Bake"))
                {
                    myAsset.bakeAsset();
                }
            }
        }

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

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

        myAsset.prShowAssetSettings = HoudiniGUI.foldout("Asset Settings", myAsset.prShowAssetSettings, true);
        if (myAsset.prShowAssetSettings)
        {
            generateAssetSettings();
        }

        ///////////////////////////////////////////////////////////////////////
        // Draw Baking Controls

        if (!myAsset.isPrefab())
        {
            myAsset.prShowBakeOptions = HoudiniGUI.foldout("Bake Animations", myAssetOTL.prShowBakeOptions, true);
            if (myAsset.prShowBakeOptions)
            {
                generateAssetBakeControls();
            }
        }

        ///////////////////////////////////////////////////////////////////////
        // Draw Paint Tools
#if !HAPI_PAINT_SUPPORT
        if (!myAsset.isPrefab())
        {
            myAsset.prShowPaintTools = HoudiniGUI.foldout("Paint Tools", myAssetOTL.prShowPaintTools, true);
            if (myAsset.prShowPaintTools)
            {
                generatePaintToolGUI();
            }
        }
#endif // !HAPI_PAINT_SUPPORT

        GUI.enabled = gui_enable;
    }