Beispiel #1
0
		public void PopulateInputPreset(HEU_InputPreset inputPreset)
		{
			inputPreset._inputObjectType = _inputObjectType;

			inputPreset._inputAssetName = _inputAsset != null ? _inputAsset.name : "";

			inputPreset._inputIndex = _inputIndex;
			inputPreset._inputName = _inputName;

			inputPreset._keepWorldTransform = _keepWorldTransform;
			inputPreset._packGeometryBeforeMerging = _packGeometryBeforeMerging;

			foreach (HEU_InputObjectInfo inputObject in _inputObjects)
			{
				HEU_InputObjectPreset inputObjectPreset = new HEU_InputObjectPreset();

				inputObjectPreset._gameObjectName = inputObject._gameObject != null ? inputObject._gameObject.name : "";
				inputObjectPreset._useTransformOffset = inputObject._useTransformOffset;
				inputObjectPreset._translateOffset = inputObject._translateOffset;
				inputObjectPreset._rotateOffset = inputObject._rotateOffset;
				inputObjectPreset._scaleOffset = inputObject._scaleOffset;

				inputPreset._inputObjectPresets.Add(inputObjectPreset);
			}

		}
Beispiel #2
0
		public void PopulateInputPreset(HEU_InputPreset inputPreset)
		{
			inputPreset._inputObjectType = _inputObjectType;

			inputPreset._inputAssetName = _inputAsset != null ? _inputAsset.name : "";

			inputPreset._inputIndex = _inputIndex;
			inputPreset._inputName = _inputName;

			inputPreset._keepWorldTransform = _keepWorldTransform;
			inputPreset._packGeometryBeforeMerging = _packGeometryBeforeMerging;

			foreach (HEU_InputObjectInfo inputObject in _inputObjects)
			{
				HEU_InputObjectPreset inputObjectPreset = new HEU_InputObjectPreset();

				if (inputObject._gameObject != null)
				{
					inputObjectPreset._gameObjectName = inputObject._gameObject.name;

					// Tag whether scene or project input object
					inputObjectPreset._isSceneObject = !HEU_GeneralUtility.IsGameObjectInProject(inputObject._gameObject);
					if (!inputObjectPreset._isSceneObject)
					{
						// For inputs in project, use the project path as name
						inputObjectPreset._gameObjectName = HEU_AssetDatabase.GetAssetOrScenePath(inputObject._gameObject);
					}
				}
				else
				{
					inputObjectPreset._gameObjectName = "";
				}

				inputObjectPreset._useTransformOffset = inputObject._useTransformOffset;
				inputObjectPreset._translateOffset = inputObject._translateOffset;
				inputObjectPreset._rotateOffset = inputObject._rotateOffset;
				inputObjectPreset._scaleOffset = inputObject._scaleOffset;

				inputPreset._inputObjectPresets.Add(inputObjectPreset);
			}

		}
	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();
	}
	public void PopulateInputPreset(HEU_InputPreset inputPreset)
	{
	    inputPreset._inputObjectType = _inputObjectType;

	    // Deprecated and replaced with _inputAssetPresets. Leaving it in for backwards compatibility.
	    //inputPreset._inputAssetName = _inputAsset != null ? _inputAsset.name : "";

	    inputPreset._inputIndex = _inputIndex;
	    inputPreset._inputName = _inputName;

	    inputPreset._keepWorldTransform = _keepWorldTransform;
	    inputPreset._packGeometryBeforeMerging = _packGeometryBeforeMerging;

	    foreach (HEU_InputObjectInfo inputObject in _inputObjects)
	    {
		HEU_InputObjectPreset inputObjectPreset = new HEU_InputObjectPreset();

		if (inputObject._gameObject != null)
		{
		    inputObjectPreset._gameObjectName = inputObject._gameObject.name;

		    // Tag whether scene or project input object
		    inputObjectPreset._isSceneObject = !HEU_GeneralUtility.IsGameObjectInProject(inputObject._gameObject);
		    if (!inputObjectPreset._isSceneObject)
		    {
			// For inputs in project, use the project path as name
			inputObjectPreset._gameObjectName = HEU_AssetDatabase.GetAssetOrScenePath(inputObject._gameObject);
		    }
		}
		else
		{
		    inputObjectPreset._gameObjectName = "";
		}

		inputObjectPreset._useTransformOffset = inputObject._useTransformOffset;
		inputObjectPreset._translateOffset = inputObject._translateOffset;
		inputObjectPreset._rotateOffset = inputObject._rotateOffset;
		inputObjectPreset._scaleOffset = inputObject._scaleOffset;

		inputPreset._inputObjectPresets.Add(inputObjectPreset);
	    }

	    foreach (HEU_InputHDAInfo hdaInfo in _inputAssetInfos)
	    {
		HEU_InputAssetPreset inputAssetPreset = new HEU_InputAssetPreset();

		if (hdaInfo._connectedGO != null)
		{
		    if (!HEU_GeneralUtility.IsGameObjectInProject(hdaInfo._connectedGO))
		    {
			inputAssetPreset._gameObjectName = hdaInfo._connectedGO.name;
		    }
		    else
		    {
			inputAssetPreset._gameObjectName = "";
		    }

		    inputPreset._inputAssetPresets.Add(inputAssetPreset);
		}
	    }
	}
Beispiel #5
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();
		}