public void init(HoudiniObjectControl object_control) { init((HoudiniControl)object_control); prObjectId = object_control.prObjectId; prObjectName = object_control.prObjectName; prObjectVisible = object_control.prObjectVisible; }
public void init( HoudiniObjectControl object_control ) { init( (HoudiniControl) object_control ); prObjectId = object_control.prObjectId; prObjectName = object_control.prObjectName; prObjectVisible = object_control.prObjectVisible; }
private bool createObject(int object_id, bool reload_asset) { bool needs_recook = false; HoudiniObjectControl object_control = null; HAPI_ObjectInfo object_info = prObjects[object_id]; // Create main underling. if (prGameObjects[object_id] == null) { prGameObjects[object_id] = new GameObject(object_info.name); prGameObjects[object_id].transform.parent = transform; prGameObjects[object_id].isStatic = gameObject.isStatic; object_control = prGameObjects[object_id].AddComponent <HoudiniObjectControl>(); object_control.init( prAssetId, object_info.nodeId, prAsset, object_info.nodeId, object_info.name, object_info.isVisible); } else { object_control = prGameObjects[object_id].GetComponent <HoudiniObjectControl>(); } GameObject main_child = prGameObjects[object_id]; try { needs_recook |= object_control.refresh(reload_asset, object_info); if (reload_asset || object_info.hasTransformChanged) { // Get transforms. HAPI_Transform trans = prObjectTransforms[object_id]; HoudiniAssetUtility.applyTransform(trans, main_child.transform); } } catch (HoudiniError error) { DestroyImmediate(main_child); prGameObjects[object_id] = null; error.addMessagePrefix("Obj(id: " + object_info.nodeId + ", name: " + object_info.name + ")"); error.addMessageDetail("Object Path: " + object_info.objectInstancePath); throw; } return(needs_recook); }
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.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; }