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

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

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

		HoudiniGUI.separator();

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

		HoudiniGUI.separator();

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

		HoudiniGUI.separator();

		// Enable particles
		{
			bool value = HoudiniHost.prEnablePointsAsParticles;
			bool changed = HoudiniGUI.toggle(
				"enable_points_as_particles",
				"Create Points as Particles", 
				ref value, myUndoInfo,
				ref myUndoInfo.enablePointsAsParticles );
			if ( changed )
			{
				HoudiniHost.prEnablePointsAsParticles = value;
			}
		}
	}
Ejemplo n.º 3
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;
            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 (GUILayout.Button("Recook"))
            {
                myAssetMerger.buildClientSide();
            }
        }

        GUI.enabled = gui_enable;
    }