Ejemplo n.º 1
0
	/// <summary>
	/// Draw asset options for given asset.
	/// </summary>
	/// <param name="asset">The HDA asset</param>
	/// <param name="assetObject">Serialized HDA asset object</param>
	private void DrawAssetOptions(HEU_HoudiniAsset asset, SerializedObject assetObject)
	{
	    GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
	    buttonStyle.fontSize = 12;
	    buttonStyle.alignment = TextAnchor.MiddleCenter;
	    buttonStyle.fixedHeight = 24;

	    HEU_EditorUI.BeginSection();
	    {
		SerializedProperty showHDAOptionsProperty = assetObject.FindProperty("_showHDAOptions");

		showHDAOptionsProperty.boolValue = HEU_EditorUI.DrawFoldOut(showHDAOptionsProperty.boolValue, "ASSET OPTIONS");
		if (showHDAOptionsProperty.boolValue)
		{
		    EditorGUI.indentLevel++;

		    EditorGUILayout.BeginHorizontal();

		    EditorGUILayout.BeginVertical();

		    HEU_EditorUI.BeginSimpleSection("Cook Triggers");
			HEU_EditorUI.DrawPropertyField(assetObject, "_autoCookOnParameterChange", "Parameter Change", "Automatically cook when a parameter changes. If off, must use Recook to cook.");
			HEU_EditorUI.DrawPropertyField(assetObject, "_transformChangeTriggersCooks", "Transform Change", "Changing the transform (e.g. moving) the asset in Unity will invoke cook in Houdini.");
			HEU_EditorUI.DrawPropertyField(assetObject, "_cookingTriggersDownCooks", "Downstream Cooks", "Cooking this asset will trigger dependent assets' to also cook.");
			HEU_EditorUI.DrawPropertyField(assetObject, "_sessionSyncAutoCook", "Session Sync: Auto Cook", "When using Session Sync, this asset will automatically cook and generated output when it is cooked separately in Houdini (e.g. via parm changes).");
		    HEU_EditorUI.EndSimpleSection();

		    HEU_EditorUI.BeginSimpleSection("Miscellaneous");
			HEU_EditorUI.DrawPropertyField(assetObject, "_pushTransformToHoudini", "Push Transform To Houdini", "Send the asset's transform to Houdini and apply to object.");
			HEU_EditorUI.DrawPropertyField(assetObject, "_ignoreNonDisplayNodes", "Ignore Non-Display Nodes", "Only display node geometry will be created.");
			HEU_EditorUI.DrawPropertyField(assetObject, "_splitGeosByGroup", "Split Geos By Group", "Split geometry into separate gameobjects by group. Deprecated feature and only recommended for simple use cases.");
		    HEU_EditorUI.EndSimpleSection();

		    EditorGUILayout.EndVertical();

		    EditorGUILayout.BeginVertical();
		    HEU_EditorUI.BeginSimpleSection("Generate");
			HEU_EditorUI.DrawPropertyField(assetObject, "_useLODGroups", "LOD Groups", "Automatically create Unity LOD group if found.");
			HEU_EditorUI.DrawPropertyField(assetObject, "_generateNormals", "Normals", "Generate normals in Unity for output geometry.");
			HEU_EditorUI.DrawPropertyField(assetObject, "_generateTangents", "Tangents", "Generate tangents in Unity for output geometry.");
			HEU_EditorUI.DrawPropertyField(assetObject, "_generateUVs", "UVs", "Force Unity to generate UVs for output geometry.");
			HEU_EditorUI.DrawPropertyField(assetObject, "_generateMeshUsingPoints", "Using Points", "Use point attributes instead of vertex attributes for geometry. Ignores vertex attributes.");
		    HEU_EditorUI.EndSimpleSection();
		    EditorGUILayout.EndVertical();

		    EditorGUILayout.EndHorizontal();

		    if (asset.NumAttributeStores() > 0)
		    {
			HEU_EditorUI.DrawPropertyField(assetObject, "_editableNodesToolsEnabled", "Enable Editable Node Tools", "Displays Editable Node Tools and generates the node's geometry, if asset has editable nodes.");
		    }

		    if (asset.NumHandles() > 0)
		    {
			HEU_EditorUI.DrawPropertyField(assetObject, "_handlesEnabled", "Enable Handles", "Creates Houdini Handles if asset has them.");
		    }

		    EditorGUILayout.Space();

		    using (var hs = new EditorGUILayout.HorizontalScope())
		    {
			if (GUILayout.Button(_savePresetButton, buttonStyle))
			{
			    string fileName = asset.AssetName;
			    string filePattern = "heupreset";
			    string newPath = EditorUtility.SaveFilePanel("Save HDA preset", "", fileName + "." + filePattern, filePattern);
			    if (newPath != null && !string.IsNullOrEmpty(newPath))
			    {
				HEU_AssetPresetUtility.SaveAssetPresetToFile(asset, newPath);
			    }
			}

			if (GUILayout.Button(_loadPresetButton, buttonStyle))
			{
			    string fileName = asset.AssetName;
			    string filePattern = "heupreset,preset";
			    string newPath = EditorUtility.OpenFilePanel("Load HDA preset", "", filePattern);
			    if (newPath != null && !string.IsNullOrEmpty(newPath))
			    {
				HEU_AssetPresetUtility.LoadPresetFileIntoAssetAndCook(asset, newPath);
			    }
			}
		    }

		    EditorGUILayout.Space();

		    if (GUILayout.Button(_resetMaterialOverridesButton, buttonStyle))
		    {
			asset.ResetMaterialOverrides();
		    }

		    EditorGUI.indentLevel--;
		}
	    }
	    HEU_EditorUI.EndSection();

	    HEU_EditorUI.DrawSeparator();
	}
Ejemplo n.º 2
0
	private static bool DrawBakeSection(HEU_HoudiniAssetRoot assetRoot, 
	    SerializedObject assetRootSerializedObject,
	    HEU_HoudiniAsset asset, SerializedObject assetObject,
	    ref HEU_HoudiniAsset.AssetBuildAction pendingBuildAction)
	{
	    bool bSkipAutoCook = false;

	    HEU_EditorUI.BeginSection();
	    {
		SerializedProperty showBakeProperty = assetObject.FindProperty("_showBakeSection");

		showBakeProperty.boolValue = HEU_EditorUI.DrawFoldOut(showBakeProperty.boolValue, "BAKE");
		if (showBakeProperty.boolValue)
		{
		    // Bake -> New Instance, New Prefab, Existing instance or prefab

		    using (var hs = new EditorGUILayout.HorizontalScope(_mainBoxStyle))
		    {
			if (GUILayout.Button(_bakegameobjectContent, _mainButtonStyle))
			{
			    asset.BakeToNewStandalone();
			}

			GUILayout.Space(_mainButtonSeparatorDistance);

			if (GUILayout.Button(_bakeprefabContent, _mainButtonStyle))
			{
			    asset.BakeToNewPrefab();
			}
		    }

		    using (var vs = new EditorGUILayout.VerticalScope(_mainBoxStyle))
		    {
			if (GUILayout.Button(_removeheContent, _mainButtonStyle))
			{
			    pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.STRIP_HEDATA;
			    bSkipAutoCook = true;
			}
		    }

		    using (var hs2 = new EditorGUILayout.VerticalScope(_mainBoxStyle))
		    {
			if (GUILayout.Button(_bakeandreplaceContent, _mainCentredButtonStyle))
			{
			    if (assetRoot._bakeTargets == null || assetRoot._bakeTargets.Count == 0)
			    {
				// No bake target means user probably forgot to set one. So complain!
				HEU_EditorUtility.DisplayDialog("No Bake Targets", "Bake Update requires atleast one valid GameObject.\n\nDrag a GameObject or Prefab onto the Drag and drop GameObjects / Prefabs field!", "OK");
			    }
			    else
			    {
				int numTargets = assetRoot._bakeTargets.Count;
				for (int i = 0; i < numTargets; ++i)
				{
				    GameObject bakeGO = assetRoot._bakeTargets[i];
				    if (bakeGO != null)
				    {
					if (HEU_EditorUtility.IsPrefabAsset(bakeGO))
					{
					    // Prefab asset means its the source prefab, and not an instance of it
					    asset.BakeToExistingPrefab(bakeGO);
					}
					else
					{
					    // This is for all standalone (including prefab instances)
					    asset.BakeToExistingStandalone(bakeGO);
					}
				    }
				    else
				    {
					Debug.LogWarning("Unable to bake to null target at index " + i);
				    }
				}
			    }
			}

			using (var hs = new EditorGUILayout.VerticalScope(_mainButtonSetStyle))
			{
			    SerializedProperty bakeTargetsProp = assetRootSerializedObject.FindProperty("_bakeTargets");
			    if (bakeTargetsProp != null)
			    {
				EditorGUILayout.PropertyField(bakeTargetsProp, _dragAndDropField, true);
			    }
			}

			HEU_EditorUI.BeginSimpleSection("Bake Update");
			HEU_EditorUI.DrawPropertyField(assetObject, "_bakeUpdateKeepPreviousTransformValues", "Keep Previous Transform Values", "Copy previous transform values when doing a Bake Update.");
			HEU_EditorUI.EndSimpleSection();
		    }
		}
	    }
	    HEU_EditorUI.EndSection();

	    HEU_EditorUI.DrawSeparator();

	    return bSkipAutoCook;
	}