static private void createCurve() { if (!HoudiniHost.isInstallationOk()) { HoudiniHost.displayHoudiniEngineInstallInfo(); return; } // Create game object. GameObject game_object = new GameObject("curve"); // Add HAPI Object Control script component. HoudiniAssetCurve asset = game_object.AddComponent <HoudiniAssetCurve>(); asset.prAssetSubType = HAPI_AssetSubType.HAPI_ASSETSUBTYPE_CURVE; // Do first build. bool build_result = asset.buildAll(); if (!build_result) // Something is not right. Clean up and die. { DestroyImmediate(game_object); return; } // Set new object name from asset name. string asset_name = asset.prAssetInfo.name; game_object.name = asset_name; // Select the new houdini asset. GameObject[] selection = new GameObject[1]; selection[0] = game_object; Selection.objects = selection; }
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; }
static private void createMergerAsset() { if (!HoudiniHost.isInstallationOk()) { HoudiniHost.displayHoudiniEngineInstallInfo(); return; } // Create game object. GameObject game_object = new GameObject("HoudiniMergerAsset"); // Add HAPI Object Control script component. HoudiniAssetMerger asset = game_object.AddComponent <HoudiniAssetMerger>(); asset.prAssetSubType = HAPI_AssetSubType.HAPI_ASSETSUBTYPE_DEFAULT; // Do a test build to see if things are ok. bool build_result = asset.buildClientSide(); if (!build_result) // Something is not right. Clean up and die. { DestroyImmediate(game_object); return; } // Select the new houdini asset. GameObject[] selection = new GameObject[1]; selection[0] = game_object; Selection.objects = selection; }
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; }
static private void loadHipFile() { if ( !HoudiniHost.isInstallationOk() ) { HoudiniHost.displayHoudiniEngineInstallInfo(); return; } string hip_file_path = HoudiniGUIUtility.promptForHIPPath(); HoudiniAssetUtility.loadHipFile( hip_file_path ); }
static private void createHAPIObject() { if ( !HoudiniHost.isInstallationOk() ) { HoudiniHost.displayHoudiniEngineInstallInfo(); return; } string asset_file_path = HoudiniGUIUtility.promptForOTLPath(); HoudiniAssetUtility.instantiateAsset( asset_file_path ); }
static private void convertToInputAsset() { if (!HoudiniHost.isInstallationOk()) { HoudiniHost.displayHoudiniEngineInstallInfo(); return; } foreach (GameObject obj in Selection.gameObjects) { bool not_an_asset = (obj.GetComponent <HoudiniAsset>() == null); bool has_mesh_filter = (obj.GetComponent <MeshFilter>() != null); if (not_an_asset && has_mesh_filter) { obj.AddComponent <HoudiniAssetInput>(); } } }
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() { 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; }
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() { 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; }
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; }
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; }
public void OnGUI() { bool gui_enable = GUI.enabled; #if !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || (UNITY_METRO && UNITY_EDITOR)) HoudiniGUI.help(HoudiniConstants.HAPI_UNSUPPORTED_PLATFORM_MSG, MessageType.Info); GUI.enabled = false; #else if (!HoudiniHost.isInstallationOk()) { HoudiniGUI.help( HoudiniHost.getMissingEngineInstallHelpString(), MessageType.Info); GUI.enabled = false; } #endif // !( UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || ( UNITY_METRO && UNITY_EDITOR ) ) if (GUILayout.Button(HoudiniGUIUtility.mySaveHoudiniSceneLabel)) { HAPI_License license = HoudiniHost.getCurrentLicense(); string ext = "hip"; if (license == HAPI_License.HAPI_LICENSE_HOUDINI_ENGINE_INDIE || license == HAPI_License.HAPI_LICENSE_HOUDINI_INDIE) { ext = "hiplc"; } string hip_file_path = EditorUtility.SaveFilePanel("Save HIP File", "", "hscene", ext); if (hip_file_path != "") { HoudiniHost.saveScene(hip_file_path); } } if (GUILayout.Button(HoudiniGUIUtility.myLoadAssetLabel)) { string asset_file_path = HoudiniGUIUtility.promptForOTLPath(); HoudiniAssetUtility.instantiateAsset(asset_file_path); } HoudiniGUI.separator(); if (GUILayout.Button("Check for New Untracked Asset Nodes")) { HoudiniAssetUtility.checkForNewAssets(); } HoudiniGUI.separator(); if (HoudiniGUI.floatField("global_time", "Global Time", ref myTime, null, ref myTime)) { HoudiniHost.setTime(myTime); } HoudiniGUI.separator(); string path = Application.dataPath; myScrollPosition = GUILayout.BeginScrollView(myScrollPosition); if (GUILayout.Button("Instantiate Core Assets")) { try { DirectoryInfo core = new DirectoryInfo(path + "//OTLs/Core"); if (!core.Exists) { throw new HoudiniError("Project/Assets/OTLs/Core directory does not exist!"); } foreach (FileInfo fi in core.GetFiles()) { if (fi.Extension == ".otl") { loadOTL(fi); } } } catch (System.Exception e) { Debug.LogError("Directory navigation failed: " + e.ToString()); } } #if (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || (UNITY_METRO && UNITY_EDITOR)) DirectoryInfo di = new DirectoryInfo(path + "//OTLs"); try { if (!di.Exists) { throw new HoudiniError("Project/Assets/OTLs directory does not exist!"); } foreach (DirectoryInfo child_directory in di.GetDirectories()) { OTLDirectory otlDir = null; foreach (OTLDirectory existingOTLDir in myOTLDirectories) { if (existingOTLDir.myDirectoryName == child_directory.Name) { otlDir = existingOTLDir; break; } } if (otlDir == null) { otlDir = new OTLDirectory(); otlDir.myDirectoryName = child_directory.Name; otlDir.myDirectoryPath = child_directory.FullName; otlDir.myExpanded = false; myOTLDirectories.Add(otlDir); } otlDir.myExpanded = EditorGUILayout.Foldout(otlDir.myExpanded, new GUIContent(otlDir.myDirectoryName)); if (otlDir.myDirectoryName == "Core") { otlDir.myExpanded = true; } if (otlDir.myExpanded) { DirectoryInfo dirContents = new DirectoryInfo(otlDir.myDirectoryPath); foreach (FileInfo fi in dirContents.GetFiles()) { if (fi.Extension == ".otl") { genOTLEntry(fi); } } } } } catch (System.Exception e) { Debug.LogError("Directory navigation failed: " + e.ToString()); } #endif // ( UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || ( UNITY_METRO && UNITY_EDITOR ) ) GUILayout.EndScrollView(); GUI.enabled = gui_enable; }