Exemplo n.º 1
0
	public void LoadPreset(HEU_SessionBase session, HEU_InputPreset inputPreset)
	{
	    ResetInputNode(session);

	    ChangeInputType(session, inputPreset._inputObjectType);

	    if (inputPreset._inputObjectType == InputObjectType.UNITY_MESH)
	    {
		bool bSet = false;
		int numObjects = inputPreset._inputObjectPresets.Count;
		for (int i = 0; i < numObjects; ++i)
		{
		    bSet = false;

		    if (!string.IsNullOrEmpty(inputPreset._inputObjectPresets[i]._gameObjectName))
		    {
			GameObject inputGO = null;
			if (inputPreset._inputObjectPresets[i]._isSceneObject)
			{
			    inputGO = HEU_GeneralUtility.GetGameObjectByNameInScene(inputPreset._inputObjectPresets[i]._gameObjectName);
			}
			else
			{
			    // Use the _gameObjectName as path to find in scene
			    inputGO = HEU_AssetDatabase.LoadAssetAtPath(inputPreset._inputObjectPresets[i]._gameObjectName, typeof(GameObject)) as GameObject;
			    if (inputGO == null)
			    {
				Debug.LogErrorFormat("Unable to find input at {0}", inputPreset._inputObjectPresets[i]._gameObjectName);
			    }
			}

			if (inputGO != null)
			{
			    HEU_InputObjectInfo inputObject = InternalAddInputObjectAtEnd(inputGO);
			    bSet = true;

			    inputObject._useTransformOffset = inputPreset._inputObjectPresets[i]._useTransformOffset;
			    inputObject._translateOffset = inputPreset._inputObjectPresets[i]._translateOffset;
			    inputObject._rotateOffset = inputPreset._inputObjectPresets[i]._rotateOffset;
			    inputObject._scaleOffset = inputPreset._inputObjectPresets[i]._scaleOffset;
			}
			else
			{
			    Debug.LogWarningFormat("Gameobject with name {0} not found. Unable to set input object.", inputPreset._inputAssetName);
			}
		    }

		    if (!bSet)
		    {
			// Add dummy spot (user can replace it manually)
			InternalAddInputObjectAtEnd(null);
		    }
		}
	    }
	    else if (inputPreset._inputObjectType == HEU_InputNode.InputObjectType.HDA)
	    {
		bool bSet = false;
		int numInptus = inputPreset._inputAssetPresets.Count;
		for (int i = 0; i < numInptus; ++i)
		{
		    bSet = false;
		    if (!string.IsNullOrEmpty(inputPreset._inputAssetPresets[i]._gameObjectName))
		    {
			bSet = FindAddToInputHDA(inputPreset._inputAssetPresets[i]._gameObjectName);
		    }

		    if (!bSet)
		    {
			// Couldn't add for some reason, so just add dummy spot (user can replace it manually)
			InternalAddInputHDAAtEnd(null);
		    }
		}

		if (numInptus == 0 && !string.IsNullOrEmpty(inputPreset._inputAssetName))
		{
		    // Old preset. Add it to input
		    FindAddToInputHDA(inputPreset._inputAssetName);
		}
	    }

	    KeepWorldTransform = inputPreset._keepWorldTransform;
	    PackGeometryBeforeMerging = inputPreset._packGeometryBeforeMerging;

	    RequiresUpload = true;

	    ClearUICache();
	}
Exemplo n.º 2
0
		public void LoadPreset(HEU_SessionBase session, HEU_InputPreset inputPreset)
		{
			ResetInputNode(session);

			ChangeInputType(session, inputPreset._inputObjectType);

			if (inputPreset._inputObjectType == HEU_InputNode.InputObjectType.UNITY_MESH)
			{
				int numObjects = inputPreset._inputObjectPresets.Count;
				for (int i = 0; i < numObjects; ++i)
				{
					if (!string.IsNullOrEmpty(inputPreset._inputObjectPresets[i]._gameObjectName))
					{
						GameObject inputGO = null;
						if (inputPreset._inputObjectPresets[i]._isSceneObject)
						{
							inputGO = HEU_GeneralUtility.GetGameObjectByNameInScene(inputPreset._inputObjectPresets[i]._gameObjectName);
						}
						else
						{
							// Use the _gameObjectName as path to find in scene
							inputGO = HEU_AssetDatabase.LoadAssetAtPath(inputPreset._inputObjectPresets[i]._gameObjectName, typeof(GameObject)) as GameObject;
							if(inputGO == null)
							{
								Debug.LogErrorFormat("Unable to find input at {0}", inputPreset._inputObjectPresets[i]._gameObjectName);
							}
						}

						if (inputGO != null)
						{
							HEU_InputObjectInfo inputObject = AddInputObjectAtEnd(inputGO);
							inputObject._useTransformOffset = inputPreset._inputObjectPresets[i]._useTransformOffset;
							inputObject._translateOffset = inputPreset._inputObjectPresets[i]._translateOffset;
							inputObject._rotateOffset = inputPreset._inputObjectPresets[i]._rotateOffset;
							inputObject._scaleOffset = inputPreset._inputObjectPresets[i]._scaleOffset;
						}
						else
						{
							Debug.LogWarningFormat("Gameobject with name {0} not found. Unable to set input object.", inputPreset._inputAssetName);
						}
					}
				}
			}
			else if (inputPreset._inputObjectType == HEU_InputNode.InputObjectType.HDA)
			{
				if (!string.IsNullOrEmpty(inputPreset._inputAssetName))
				{
					GameObject inputAsset = GameObject.Find(inputPreset._inputAssetName);
					if (inputAsset != null)
					{
						HEU_HoudiniAssetRoot inputAssetRoot = inputAsset != null ? inputAsset.GetComponent<HEU_HoudiniAssetRoot>() : null;
						if (inputAssetRoot != null && inputAssetRoot._houdiniAsset != null)
						{
							// Need to reconnect and make sure connected asset is in this session

							_inputAsset = inputAsset;

							if (!inputAssetRoot._houdiniAsset.IsAssetValidInHoudini(session))
							{
								inputAssetRoot._houdiniAsset.RequestCook(true, false, true, true);
							}

							_connectedNodeID = inputAssetRoot._houdiniAsset.AssetID;

							_parentAsset.ConnectToUpstream(inputAssetRoot._houdiniAsset);

							_connectedInputAsset = _inputAsset;
						}
						else
						{
							Debug.LogErrorFormat("Input HDA with name {0} is not a valid asset (missing components). Unable to set input asset.", inputPreset._inputAssetName);
						}
					}
					else
					{
						Debug.LogWarningFormat("Game with name {0} not found. Unable to set input asset.", inputPreset._inputAssetName);
					}
				}
			}

			KeepWorldTransform = inputPreset._keepWorldTransform;
			PackGeometryBeforeMerging = inputPreset._packGeometryBeforeMerging;

			RequiresUpload = true;

			ClearUICache();
		}