Ejemplo n.º 1
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);
    }
Ejemplo n.º 2
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);
    }
    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;
    }
Ejemplo n.º 4
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 ];

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

		HoudiniGUIParm gui_parm 	= new HoudiniGUIParm( parm );

		// Overridden parameters should not be bold in play mode.
		gui_parm.isBold				= myParms.isParmOverridden( parm.id ) && 
									  !EditorApplication.isPlayingOrWillChangePlaymode;

		///////////////////////////////////////////////////////////////////////
		// 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.prParmChoiceLists[ 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.prParmChoiceLists[ parm.choiceIndex + i ].label );
					values.Add( myParms.prParmChoiceLists[ 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.isFilePath() )
		{
			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)";

			string file_pattern = parm.typeInfo;
			if ( file_pattern != "" )
				gui_parm.label += " (" + file_pattern + ")";

			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.isNodePath() )
		{
			bool gui_enable = GUI.enabled;
			GUI.enabled = false; // This is not yet supported.

			string op_filter = parm.typeInfo;
			if ( op_filter != "" )
				gui_parm.label += " (" + op_filter + ")";

			UnityEngine.Object temp_object = null;
			HoudiniGUI.objectField(
				ref gui_parm, ref temp_object, typeof( GameObject ),
				ref join_last, ref no_label_toggle_last );

			GUI.enabled = gui_enable;
		}
		///////////////////////////////////////////////////////////////////////
		// 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.prParmChoiceLists[ 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;
	}
    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());
    }
Ejemplo n.º 6
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;
    }
Ejemplo n.º 7
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;

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

        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;
    }
Ejemplo n.º 8
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 !( 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;
    }
Ejemplo n.º 9
0
    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;
    }
Ejemplo n.º 10
0
	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 !( 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;

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

			Object input_object = myAssetMerger.prInputObject as Object;
			HoudiniGUI.objectField( "input_object", "Input Object", ref input_object, typeof( GameObject ) );
			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 ( !myAssetMerger.isPrefab() )
			{
				if ( GUILayout.Button( "Recook" ) )
					myAssetMerger.buildClientSide();
			}
		}

		GUI.enabled = gui_enable;
	}