Ejemplo n.º 1
0
		private void DrawInputNodesSection(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			List<HEU_InputNode> inputNodes = asset.GetNonParameterInputNodes();
			if (inputNodes.Count > 0)
			{
				HEU_EditorUI.BeginSection();

				SerializedProperty showInputNodesProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_showInputNodesSection");
				if (showInputNodesProperty != null)
				{
					showInputNodesProperty.boolValue = HEU_EditorUI.DrawFoldOut(showInputNodesProperty.boolValue, "INPUT NODES");
					if (showInputNodesProperty.boolValue)
					{
						foreach (HEU_InputNode inputNode in inputNodes)
						{
							HEU_InputNodeUI.EditorDrawInputNode(inputNode);

							if (inputNodes.Count > 1)
							{
								HEU_EditorUI.DrawSeparator();
							}
						}
					}

					HEU_EditorUI.DrawSeparator();
				}

				HEU_EditorUI.EndSection();

				HEU_EditorUI.DrawSeparator();
			}
		}
Ejemplo n.º 2
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)
		{
			HEU_EditorUI.BeginSection();
			{
				SerializedProperty showHDAOptionsProperty = assetObject.FindProperty("_showHDAOptions");

				showHDAOptionsProperty.boolValue = HEU_EditorUI.DrawFoldOut(showHDAOptionsProperty.boolValue, "ASSET OPTIONS");
				if (showHDAOptionsProperty.boolValue)
				{
					EditorGUI.indentLevel++;
					HEU_EditorUI.DrawPropertyField(assetObject, "_autoCookOnParameterChange", "Auto-Cook On Parameter Change");
					HEU_EditorUI.DrawPropertyField(assetObject, "_pushTransformToHoudini", "Push Transform To Houdini");
					HEU_EditorUI.DrawPropertyField(assetObject, "_transformChangeTriggersCooks", "Transform Change Triggers Cooks");
					HEU_EditorUI.DrawPropertyField(assetObject, "_cookingTriggersDownCooks", "Cooking Triggers Downstream Cooks");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateUVs", "Generate UVs");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateTangents", "Generate Tangents");
					HEU_EditorUI.DrawPropertyField(assetObject, "_ignoreNonDisplayNodes", "Ignore NonDisplay Nodes");

					if (asset.NumAttributeStores() > 0)
					{
						HEU_EditorUI.DrawPropertyField(assetObject, "_editableNodesToolsEnabled", "Enable Editable Node Tools");
					}

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

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

			HEU_EditorUI.DrawSeparator();
		}
Ejemplo n.º 3
0
		private bool DrawDetailsGeometry()
		{
			bool bChanged = false;

			EditorGUIUtility.labelWidth = 250;

			// TODO
			{
				bool oldValue = HEU_PluginSettings.Curves_ShowInSceneView;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Show Curves in Scene View");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.Curves_ShowInSceneView = newValue;
					HEU_HoudiniAsset.SetCurvesVisibilityInScene(newValue);
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				float oldValue = HEU_PluginSettings.NormalGenerationThresholdAngle;
				float newValue = EditorGUILayout.DelayedFloatField("Normal Generation Threshold Angle", oldValue);
				if (newValue != oldValue)
				{
					HEU_PluginSettings.NormalGenerationThresholdAngle = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();

			EditorGUIUtility.labelWidth = 0;

			return bChanged;
		}
Ejemplo n.º 4
0
		private static bool DrawSection(HEU_SettingsWindow settingsWindow, string sectionLabel, DrawDetailsDelegate drawDetailsDelegate, ref bool foldoutState)
		{
			bool bChanged = false;

			HEU_EditorUI.BeginSection();
			{
				foldoutState = HEU_EditorUI.DrawFoldOut(foldoutState, sectionLabel);
				if (foldoutState)
				{
					HEU_EditorUI.DrawSeparator();
					EditorGUI.indentLevel++;

					using (var hs = new EditorGUILayout.HorizontalScope())
					{
						using (var vs = new EditorGUILayout.VerticalScope())
						{
							bChanged |= drawDetailsDelegate();
						}
					}

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

			HEU_EditorUI.DrawSeparator();

			return bChanged;
		}
Ejemplo n.º 5
0
		private bool DrawToolSettings()
		{
			bool bChanged = false;

			HEU_EditorUI.DrawSeparator();
			{
				float oldValue = HEU_PluginSettings.ImageGamma;
				float newValue = EditorGUILayout.DelayedFloatField("Texture Gamma", oldValue);
				if (newValue != oldValue)
				{
					HEU_PluginSettings.ImageGamma = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				Color oldValue = HEU_PluginSettings.LineColor;
				Color newValue = EditorGUILayout.ColorField("Line Color", oldValue);
				if (newValue != oldValue)
				{
					HEU_PluginSettings.LineColor = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();

			return bChanged;
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Draw Asset Events section.
		/// </summary>
		/// <param name="asset"></param>
		/// <param name="assetObject"></param>
		private void DrawEventsSection(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			HEU_EditorUI.BeginSection();
			{
				SerializedProperty showEventsProperty = assetObject.FindProperty("_showEventsSection");

				showEventsProperty.boolValue = HEU_EditorUI.DrawFoldOut(showEventsProperty.boolValue, "EVENTS");
				if (showEventsProperty.boolValue)
				{
					HEU_EditorUI.DrawSeparator();

					SerializedProperty reloadEvent = assetObject.FindProperty("_reloadEvent");
					EditorGUILayout.PropertyField(reloadEvent, new GUIContent("Rebuild Events"));

					HEU_EditorUI.DrawSeparator();

					SerializedProperty recookEvent = assetObject.FindProperty("_cookedEvent");
					EditorGUILayout.PropertyField(recookEvent, new GUIContent("Cooked Events"));

					HEU_EditorUI.DrawSeparator();

					SerializedProperty bakedEvent = assetObject.FindProperty("_bakedEvent");
					EditorGUILayout.PropertyField(bakedEvent, new GUIContent("Baked Events"));
				}
			}

			HEU_EditorUI.EndSection();

			HEU_EditorUI.DrawSeparator();
		}
Ejemplo n.º 7
0
		private bool DrawDetailsEnvironment()
		{
			bool bChanged = false;

			{
				string oldPath = HEU_PluginSettings.HoudiniEngineEnvFilePath;
				string fileExt = "env";

				using (new EditorGUILayout.HorizontalScope())
				{
					string newPath = EditorGUILayout.DelayedTextField(new GUIContent("Houdini Env File", "Assets/ relative path to unity_houdini.env file containing environment paths"), oldPath);

					GUIStyle buttonStyle = HEU_EditorUI.GetNewButtonStyle_MarginPadding(0, 0);
					if (GUILayout.Button("...", buttonStyle, GUILayout.Width(30), GUILayout.Height(18)))
					{
						string openFilePath = UnityEditor.EditorUtility.OpenFilePanel("Select Houdini Env file", newPath, fileExt);
						if (!string.IsNullOrEmpty(openFilePath))
						{
							newPath = openFilePath;
						}
					}

					if (!newPath.Equals(oldPath))
					{
						HEU_PluginSettings.HoudiniEngineEnvFilePath = newPath;
						bChanged = true;
					}

					GUILayout.Space(5);

					if (GUILayout.Button(_refreshContent, buttonStyle, GUILayout.Width(40), GUILayout.Height(18)))
					{
						HEU_PluginStorage.Instance.LoadAssetEnvironmentPaths();
					}
				}
			}
			HEU_EditorUI.DrawSeparator();

			Dictionary<string, string> envMap = HEU_PluginStorage.Instance.GetEnvironmentPathMap();
			if (envMap == null)
			{
				HEU_EditorUI.DrawHeadingLabel("No environment mapped paths found!");
			}
			else
			{
				HEU_EditorUI.DrawHeadingLabel("Enviornment Mapped Paths:");
				EditorGUILayout.LabelField("The following mappings will be applied to assets loaded from outside the Assets/ folder.");

				foreach (KeyValuePair<string, string> pair in envMap)
				{
					EditorGUILayout.LabelField(string.Format("{0} = {1}", pair.Key, pair.Value));
				}

				HEU_EditorUI.DrawSeparator();
			}

			return bChanged;
		}
Ejemplo n.º 8
0
		private bool DrawDetailsCooking()
		{
			bool bChanged = false;

			{
				bool oldValue = HEU_PluginSettings.CookingEnabled;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Enable Cooking");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.CookingEnabled = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.CookingTriggersDownstreamCooks;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Cooking Triggers Downstream Cooks");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.CookingTriggersDownstreamCooks = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.PushUnityTransformToHoudini;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Push Unity Transform To Houdini");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.PushUnityTransformToHoudini = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.TransformChangeTriggersCooks;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Transform Change Triggers Cooks");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.TransformChangeTriggersCooks = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.CookTemplatedGeos;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Import Templated Geos");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.CookTemplatedGeos = newValue;
					bChanged = true;
				}
			}

			return bChanged;
		}
Ejemplo n.º 9
0
		private void DrawNoHDAInfo()
		{
			HEU_EditorUI.DrawSeparator();

			GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
			labelStyle.fontStyle = FontStyle.Bold;
			labelStyle.normal.textColor = HEU_EditorUI.IsEditorDarkSkin() ? Color.yellow : Color.red;
			EditorGUILayout.LabelField("Houdini Engine Asset - no HEU_HoudiniAsset found!", labelStyle);

			HEU_EditorUI.DrawSeparator();
		}
Ejemplo n.º 10
0
        /// <summary>
        /// Draw the Houdini Engine header image
        /// </summary>
        void DrawHeaderSection()
        {
            GUI.backgroundColor = new Color(0.2f, 0.2f, 0.2f);
            Texture2D headerImage = Resources.Load("heu_hengine") as Texture2D;

            HEU_EditorUI.BeginSection();
            GUILayout.Label(headerImage, GUILayout.MinWidth(100));
            HEU_EditorUI.EndSection();

            GUI.backgroundColor = Color.white;

            HEU_EditorUI.DrawSeparator();
        }
Ejemplo n.º 11
0
	/// <summary>
	/// Draw the Houdini Engine header image
	/// </summary>
	public static void DrawHeaderSection()
	{
	    GUI.backgroundColor = new Color(0.2f, 0.2f, 0.2f);
	    string fileName = HEU_EditorUI.IsEditorDarkSkin() ? "heu_hengine_d" : "heu_hengine";
	    Texture2D headerImage = Resources.Load(fileName) as Texture2D;

	    HEU_EditorUI.DrawSeparator();
	    //HEU_EditorUI.BeginSection();
	    GUILayout.Label(headerImage);
	    //HEU_EditorUI.EndSection();

	    GUI.backgroundColor = Color.white;
	}
Ejemplo n.º 12
0
	private void DrawHDAUIMessage(string msg)
	{
	    HEU_EditorUI.DrawSeparator();

	    GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
	    labelStyle.fontStyle = FontStyle.Bold;
	    labelStyle.normal.textColor = HEU_EditorUI.IsEditorDarkSkin() ? Color.yellow : Color.red;
	    labelStyle.alignment = TextAnchor.MiddleCenter;
	    labelStyle.wordWrap = true;
	    EditorGUILayout.LabelField(msg, labelStyle);

	    HEU_EditorUI.DrawSeparator();
	}
Ejemplo n.º 13
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 = 11;
			buttonStyle.alignment = TextAnchor.MiddleCenter;
			buttonStyle.fixedHeight = 24;
			buttonStyle.margin.left = 34;

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

				showHDAOptionsProperty.boolValue = HEU_EditorUI.DrawFoldOut(showHDAOptionsProperty.boolValue, "ASSET OPTIONS");
				if (showHDAOptionsProperty.boolValue)
				{
					EditorGUI.indentLevel++;
					HEU_EditorUI.DrawPropertyField(assetObject, "_autoCookOnParameterChange", "Auto-Cook On Parameter Change");
					HEU_EditorUI.DrawPropertyField(assetObject, "_pushTransformToHoudini", "Push Transform To Houdini");
					HEU_EditorUI.DrawPropertyField(assetObject, "_transformChangeTriggersCooks", "Transform Change Triggers Cooks");
					HEU_EditorUI.DrawPropertyField(assetObject, "_cookingTriggersDownCooks", "Cooking Triggers Downstream Cooks");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateUVs", "Generate UVs");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateTangents", "Generate Tangents");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateNormals", "Generate Normals");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateMeshUsingPoints", "Generate Mesh Using Points");
					HEU_EditorUI.DrawPropertyField(assetObject, "_useLODGroups", "Use LOD Groups");
					HEU_EditorUI.DrawPropertyField(assetObject, "_ignoreNonDisplayNodes", "Ignore NonDisplay Nodes");

					if (asset.NumAttributeStores() > 0)
					{
						HEU_EditorUI.DrawPropertyField(assetObject, "_editableNodesToolsEnabled", "Enable Editable Node Tools");
					}

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

					EditorGUILayout.Space();

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

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

			HEU_EditorUI.DrawSeparator();
		}
Ejemplo n.º 14
0
		private void DrawCurvesSection(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			if (asset.GetEditableCurveCount() <= 0)
			{
				return;
			}

			HEU_EditorUI.BeginSection();
			{
				SerializedProperty showCurvesProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_showCurvesSection");
				if (showCurvesProperty != null)
				{
					showCurvesProperty.boolValue = HEU_EditorUI.DrawFoldOut(showCurvesProperty.boolValue, "CURVES");
					if (showCurvesProperty.boolValue)
					{
						SerializedProperty curveEditorProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveEditorEnabled");
						if (curveEditorProperty != null)
						{
							EditorGUILayout.PropertyField(curveEditorProperty);
						}

						SerializedProperty curveCollisionProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveDrawCollision");
						if (curveCollisionProperty != null)
						{
							EditorGUILayout.PropertyField(curveCollisionProperty, new GUIContent("Draw Collision Type"));
							if (curveCollisionProperty.enumValueIndex == (int)HEU_Curve.CurveDrawCollision.COLLIDERS)
							{
								HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveDrawColliders", label: "Colliders");
							}
							else if (curveCollisionProperty.enumValueIndex == (int)HEU_Curve.CurveDrawCollision.LAYERMASK)
							{
								HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveDrawLayerMask", label: "Layer Mask");
							}
						}

						List<HEU_Curve> curves = asset.GetCurves();
						for (int i = 0; i < curves.Count; ++i)
						{
							if (curves[i].Parameters != null)
							{
								DrawParameters(curves[i].Parameters, ref _curveParameterEditor);
							}
						}
					}
				}
			}
			HEU_EditorUI.EndSection();

			HEU_EditorUI.DrawSeparator();
		}
Ejemplo n.º 15
0
		/// <summary>
		/// Draw Houdini Engine license info.
		/// </summary>
		private void DrawLicenseInfo()
		{
			HAPI_License license = HEU_SessionManager.GetCurrentLicense(false);
			if (license == HAPI_License.HAPI_LICENSE_HOUDINI_ENGINE_INDIE)
			{
				HEU_EditorUI.DrawSeparator();

				GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
				labelStyle.fontStyle = FontStyle.Bold;
				labelStyle.normal.textColor = HEU_EditorUI.IsEditorDarkSkin() ? Color.yellow : Color.red;
				EditorGUILayout.LabelField("Houdini Engine Indie - For Limited Commercial Use Only", labelStyle);

				HEU_EditorUI.DrawSeparator();
			}
		}
Ejemplo n.º 16
0
	private bool DrawToolSettings()
	{
	    bool bChanged = false;

	    HEU_EditorUI.DrawSeparator();
	    {
		float oldValue = HEU_PluginSettings.ImageGamma;
		float newValue = EditorGUILayout.DelayedFloatField("Texture Gamma", oldValue);
		if (newValue != oldValue)
		{
		    HEU_PluginSettings.ImageGamma = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();
	    {
		Color oldValue = HEU_PluginSettings.LineColor;
		Color newValue;
		if (HEU_PluginSettings.UseHDRColor)
		{
		    newValue = EditorGUILayout.ColorField(new GUIContent("Line Color", "Color of the line"), oldValue, true, true, true);
		}
		else
		{
		    newValue = EditorGUILayout.ColorField(new GUIContent("Line Color", "Color of the line"), oldValue);
		}

		if (newValue != oldValue)
		{
		    HEU_PluginSettings.LineColor = newValue;
		    bChanged = true;
		}
	    }

	    HEU_EditorUI.DrawSeparator();
	    {
		bool oldValue = HEU_PluginSettings.UseHybridCurveEditing;
		bool newValue =  HEU_EditorUI.DrawToggleLeft(oldValue, "Use Hybrid Curve Editing", "Toggles the usage of 'Hybrid Curve Editing', which overrides the shift function when working with curves.");
		if (oldValue != newValue)
		{
		    HEU_PluginSettings.UseHybridCurveEditing = newValue;
		    bChanged = true;
		}
	    }

	    return bChanged;
	}
Ejemplo n.º 17
0
	private bool DrawDetailsMaterials()
	{
	    bool bChanged = false;

	    HEU_PipelineType pipeline = HEU_RenderingPipelineDefines.GetPipeline();

	    bool isBuiltInRenderPipeline = pipeline == HEU_PipelineType.BiRP;

	    // Force set UseLegacyShaders to prevent possible locked state
	    if (!isBuiltInRenderPipeline && HEU_PluginSettings.UseLegacyShaders == true)
	    {
		HEU_PluginSettings.UseLegacyShaders = false;
	    }

	    using (new EditorGUI.DisabledScope(!isBuiltInRenderPipeline))
	    {
		bool oldValue = HEU_PluginSettings.UseLegacyShaders;
		bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Use Legacy shaders as default", "Use the legacy shaders in case your device doesn't support shader model 3.0. Only supported for the built-in render pipeline.");
		if (newValue != oldValue)
		{
		    HEU_PluginSettings.UseLegacyShaders = newValue;
		    bChanged = true;
		}
	    }

	    bool isUsingLegacyShaders = HEU_PluginSettings.UseLegacyShaders;

	    using (new EditorGUI.DisabledScope(isUsingLegacyShaders))
	    {
		bool oldValue = HEU_PluginSettings.UseSpecularShader;
		bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Use Specular shader as default", "Use the specular workflow instead of the metallic one.");
		if (newValue != oldValue)
		{
		    HEU_PluginSettings.UseSpecularShader = newValue;
		    bChanged = true;
		}
	    }
	    HEU_EditorUI.DrawSeparator();

	    return bChanged;
	}
	public override void OnInspectorGUI()
	{
	    serializedObject.Update();

	    SerializedProperty uiLockedProperty = HEU_EditorUtility.GetSerializedProperty(serializedObject, "_uiLocked");
	    if (uiLockedProperty != null)
	    {
		EditorGUI.BeginChangeCheck();

		HEU_EditorUI.DrawSeparator();

		GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
		labelStyle.fontStyle = FontStyle.Bold;
		labelStyle.wordWrap = true;
		labelStyle.normal.textColor = HEU_EditorUI.IsEditorDarkSkin() ? Color.yellow : Color.blue;

		string lockMsg = "This contains the meta data for the HDA."
						+ "\nIt is locked out because it is not recommended to edit it.";

		EditorGUILayout.LabelField(lockMsg, labelStyle);

		HEU_EditorUI.DrawSeparator();

		uiLockedProperty.boolValue = EditorGUILayout.Toggle("UI Locked", uiLockedProperty.boolValue);

		if (EditorGUI.EndChangeCheck())
		{
		    serializedObject.ApplyModifiedProperties();
		}

		HEU_EditorUI.DrawHorizontalLine();

		using (new EditorGUI.DisabledScope(uiLockedProperty.boolValue))
		{
		    // Only draw the default if user has unlocked asset UI.
		    DrawDefaultInspector();
		}
	    }
	}
Ejemplo n.º 19
0
		/// <summary>
		/// Draw the Generate section.
		/// </summary>
		private static bool DrawGenerateSection(HEU_HoudiniAssetRoot assetRoot, SerializedObject assetRootSerializedObject, HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			bool bSkipDrawing = false;

			float separatorDistance = 5f;

			float screenWidth = EditorGUIUtility.currentViewWidth;

			float buttonHeight = 30f;
			float widthPadding = 55f;
			float doubleButtonWidth = Mathf.Round(screenWidth - widthPadding + separatorDistance);
			float singleButtonWidth = Mathf.Round((screenWidth - widthPadding) * 0.5f);

			GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
			buttonStyle.fontStyle = FontStyle.Bold;
			buttonStyle.fontSize = 11;
			buttonStyle.alignment = TextAnchor.MiddleLeft;
			buttonStyle.fixedHeight = buttonHeight;
			buttonStyle.padding.left = 6;
			buttonStyle.padding.right = 6;
			buttonStyle.margin.left = 0;
			buttonStyle.margin.right = 0;

			GUIStyle centredButtonStyle = new GUIStyle(buttonStyle);
			centredButtonStyle.alignment = TextAnchor.MiddleCenter;

			GUIStyle buttonSetStyle = new GUIStyle(GUI.skin.box);
			RectOffset br = buttonSetStyle.margin;
			br.left = 4;
			br.right = 4;
			buttonSetStyle.margin = br;

			GUIStyle boxStyle = new GUIStyle(GUI.skin.GetStyle("ColorPickerBackground"));
			br = boxStyle.margin;
			br.left = 4;
			br.right = 4;
			boxStyle.margin = br;
			boxStyle.padding = br;

			GUIStyle promptButtonStyle = new GUIStyle(GUI.skin.button);
			promptButtonStyle.fontSize = 11;
			promptButtonStyle.alignment = TextAnchor.MiddleCenter;
			promptButtonStyle.fixedHeight = 30;
			promptButtonStyle.margin.left = 34;
			promptButtonStyle.margin.right = 34;

			_recookhdaContent.text = "  Recook Asset";

			HEU_HoudiniAsset.AssetBuildAction pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.NONE;
			SerializedProperty pendingBuildProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_requestBuildAction");
			if (pendingBuildProperty != null)
			{
				pendingBuildAction = (HEU_HoudiniAsset.AssetBuildAction)pendingBuildProperty.enumValueIndex;
			}

			// Track changes for the build and bake targets
			EditorGUI.BeginChangeCheck();

			HEU_HoudiniAsset.AssetCookStatus cookStatus = GetCookStatusFromSerializedAsset(assetObject);

			if (cookStatus == HEU_HoudiniAsset.AssetCookStatus.SELECT_SUBASSET)
			{
				// Prompt user to select subasset

				GUIStyle promptStyle = new GUIStyle(GUI.skin.label);
				promptStyle.fontStyle = FontStyle.Bold;
				promptStyle.normal.textColor = HEU_EditorUI.IsEditorDarkSkin() ? Color.green : Color.blue;
				EditorGUILayout.LabelField("SELECT AN ASSET TO INSTANTIATE:", promptStyle);

				EditorGUILayout.Separator();

				int selectedIndex = -1;
				string[] subassetNames = asset.SubassetNames;

				for (int i = 0; i < subassetNames.Length; ++i)
				{
					if (GUILayout.Button(subassetNames[i], promptButtonStyle))
					{
						selectedIndex = i;
						break;
					}

					EditorGUILayout.Separator();
				}

				if (selectedIndex >= 0)
				{
					SerializedProperty selectedIndexProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_selectedSubassetIndex");
					if (selectedIndexProperty != null)
					{
						selectedIndexProperty.intValue = selectedIndex;
					}
				}

				bSkipDrawing = true;
			}
			else
			{
				HEU_EditorUI.BeginSection();
				{
					if (cookStatus == HEU_HoudiniAsset.AssetCookStatus.COOKING || cookStatus == HEU_HoudiniAsset.AssetCookStatus.POSTCOOK)
					{
						_recookhdaContent.text = "  Cooking Asset";
					}
					else if (cookStatus == HEU_HoudiniAsset.AssetCookStatus.LOADING || cookStatus == HEU_HoudiniAsset.AssetCookStatus.POSTLOAD)
					{
						_reloadhdaContent.text = "  Loading Asset";
					}

					SerializedProperty showGenerateProperty = assetObject.FindProperty("_showGenerateSection");

					showGenerateProperty.boolValue = HEU_EditorUI.DrawFoldOut(showGenerateProperty.boolValue, "GENERATE");
					if (showGenerateProperty.boolValue)
					{
						//bool bHasPendingAction = (pendingBuildAction != HEU_HoudiniAsset.AssetBuildAction.NONE) || (cookStatus != HEU_HoudiniAsset.AssetCookStatus.NONE);

						HEU_EditorUI.DrawSeparator();

						//EditorGUI.BeginDisabledGroup(bHasPendingAction);

						using (var hs = new EditorGUILayout.HorizontalScope(boxStyle))
						{
							if (GUILayout.Button(_reloadhdaContent, buttonStyle, GUILayout.Width(singleButtonWidth)))
							{
								pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.RELOAD;
								bSkipDrawing = true;
							}

							GUILayout.Space(separatorDistance);

							if (!bSkipDrawing && GUILayout.Button(_recookhdaContent, buttonStyle, GUILayout.Width(singleButtonWidth)))
							{
								pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.COOK;
								bSkipDrawing = true;
							}
						}

						using (var hs = new EditorGUILayout.HorizontalScope(boxStyle))
						{
							float tripleButtonWidth = Mathf.Round((screenWidth - widthPadding) * 0.33f);

							if (GUILayout.Button(_removeheContent, buttonStyle, GUILayout.Width(tripleButtonWidth)))
							{
								pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.STRIP_HEDATA;
								bSkipDrawing = true;
							}

							GUILayout.Space(separatorDistance);

							if (GUILayout.Button(_duplicateContent, buttonStyle, GUILayout.Width(tripleButtonWidth)))
							{
								pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.DUPLICATE;
								bSkipDrawing = true;
							}

							GUILayout.Space(separatorDistance);

							if (GUILayout.Button(_resetParamContent, buttonStyle, GUILayout.Width(tripleButtonWidth)))
							{
								pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.RESET_PARAMS;
								bSkipDrawing = true;
							}
						}

						//EditorGUI.EndDisabledGroup();

						HEU_EditorUI.DrawSeparator();
					}
				}

				HEU_EditorUI.EndSection();

				HEU_EditorUI.DrawSeparator();

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

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

							using (var vs = new EditorGUILayout.HorizontalScope(boxStyle))
							{
								if (GUILayout.Button(_bakegameobjectContent, buttonStyle, GUILayout.Width(singleButtonWidth)))
								{
									asset.BakeToNewStandalone();
								}

								GUILayout.Space(separatorDistance);

								if (GUILayout.Button(_bakeprefabContent, buttonStyle, GUILayout.Width(singleButtonWidth)))
								{
									asset.BakeToNewPrefab();
								}
							}

							HEU_EditorUI.DrawSeparator();

							using (var hs2 = new EditorGUILayout.VerticalScope(boxStyle))
							{
								if (GUILayout.Button(_bakeandreplaceContent, centredButtonStyle, GUILayout.Width(doubleButtonWidth)))
								{
									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(buttonSetStyle))
								{
									SerializedProperty bakeTargetsProp = assetRootSerializedObject.FindProperty("_bakeTargets");
									if (bakeTargetsProp != null)
									{
										EditorGUILayout.PropertyField(bakeTargetsProp, _dragAndDropField, true, GUILayout.Width(doubleButtonWidth - 9f));
									}
								}
							}
						}
					}
				}
				HEU_EditorUI.EndSection();

				HEU_EditorUI.DrawSeparator();

				if (pendingBuildAction != HEU_HoudiniAsset.AssetBuildAction.NONE)
				{
					// Sanity check to make sure the asset is part of the AssetUpater
					HEU_AssetUpdater.AddAssetForUpdate(asset);

					// Apply pending build action based on user UI interaction above
					pendingBuildProperty.enumValueIndex = (int)pendingBuildAction;

					if (pendingBuildAction == HEU_HoudiniAsset.AssetBuildAction.COOK)
					{
						// Recook should only update parameters that haven't changed. Otherwise if not checking and updating parameters,
						// then buttons will trigger callbacks on Recook which is not desired.
						SerializedProperty checkParameterChange = HEU_EditorUtility.GetSerializedProperty(assetObject, "_checkParameterChangeForCook");
						if (checkParameterChange != null)
						{
							checkParameterChange.boolValue = true;
						}
					}
				}
			}
			
			if (EditorGUI.EndChangeCheck())
			{
				assetRootSerializedObject.ApplyModifiedProperties();
				assetObject.ApplyModifiedProperties();
			}

			return bSkipDrawing;
		}
Ejemplo n.º 20
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 = 11;
			buttonStyle.alignment = TextAnchor.MiddleCenter;
			buttonStyle.fixedHeight = 24;
			buttonStyle.margin.left = 34;

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

				showHDAOptionsProperty.boolValue = HEU_EditorUI.DrawFoldOut(showHDAOptionsProperty.boolValue, "ASSET OPTIONS");
				if (showHDAOptionsProperty.boolValue)
				{
					EditorGUI.indentLevel++;
					HEU_EditorUI.DrawPropertyField(assetObject, "_autoCookOnParameterChange", "Auto-Cook On Parameter Change", "Automatically cook when a parameter changes. If off, must use Recook to cook.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_pushTransformToHoudini", "Push Transform To Houdini", "Send the asset's transform to Houdini and apply to object.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_transformChangeTriggersCooks", "Transform Change Triggers Cooks", "Changing the transform (e.g. moving) the asset in Unity will invoke cook in Houdini.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_cookingTriggersDownCooks", "Cooking Triggers Downstream Cooks", "Cooking this asset will trigger dependent assets' to also cook.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateUVs", "Generate UVs", "Force Unity to generate UVs for output geometry.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateTangents", "Generate Tangents", "Generate tangents in Unity for output geometry.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateNormals", "Generate Normals", "Generate normals in Unity for output geometry.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateMeshUsingPoints", "Generate Mesh Using Points", "Use point attributes instead of vertex attributes for geometry. Ignores vertex attributes.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_useLODGroups", "Use LOD Groups", "Automatically create Unity LOD group if found.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_ignoreNonDisplayNodes", "Ignore NonDisplay 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.");

					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, GUILayout.MaxWidth(160)))
						{
							string fileName = asset.AssetName;
							string filePattern = "preset";
							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, GUILayout.MaxWidth(160)))
						{
							string fileName = asset.AssetName;
							string filePattern = "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, GUILayout.MaxWidth(160)))
					{
						asset.ResetMaterialOverrides();
					}

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

			HEU_EditorUI.DrawSeparator();
		}
Ejemplo n.º 21
0
		/// <summary>
		/// Draw the Object Instance Inputs section for given asset.
		/// </summary>
		/// <param name="asset">The HDA asset</param>
		/// <param name="assetObject">Serialized HDA asset object</param>
		private void DrawInstanceInputs(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			HEU_EditorUI.DrawSeparator();

			// Get list of object input fields
			List<HEU_ObjectInstanceInfo> objInstanceInfos = new List<HEU_ObjectInstanceInfo>();
			asset.PopulateObjectInstanceInfos(objInstanceInfos);

			int numObjInstances = objInstanceInfos.Count;

			// Display input section if at least have 1 input field
			if (numObjInstances > 0)
			{
				HEU_EditorUI.BeginSection();

				SerializedProperty showInstanceInputsProperty = assetObject.FindProperty("_showInstanceInputs");

				showInstanceInputsProperty.boolValue = HEU_EditorUI.DrawFoldOut(showInstanceInputsProperty.boolValue, "INSTANCE INPUTS");
				if (showInstanceInputsProperty.boolValue)
				{
					EditorGUI.BeginChangeCheck();

					// Draw each instanced input info
					for (int i = 0; i < numObjInstances; ++i)
					{
						EditorGUILayout.BeginVertical();

						string inputName = objInstanceInfos[i]._partTarget.PartName + "_" + i;

						SerializedObject objInstanceSerialized = new SerializedObject(objInstanceInfos[i]);

						SerializedProperty instancedInputsProperty = HEU_EditorUtility.GetSerializedProperty(objInstanceSerialized, "_instancedInputs");
						if (instancedInputsProperty != null)
						{
							int inputCount = instancedInputsProperty.arraySize;
							EditorGUILayout.PropertyField(instancedInputsProperty, new GUIContent(inputName), true);

							// When input size increases, Unity creates default values for HEU_InstancedInput which results in
							// zero value for scale offset. This fixes it up.
							int newInputCount = instancedInputsProperty.arraySize;
							if (inputCount < newInputCount)
							{
								for (int inputIndex = inputCount; inputIndex < newInputCount; ++inputIndex)
								{
									SerializedProperty scaleProperty = instancedInputsProperty.GetArrayElementAtIndex(inputIndex).FindPropertyRelative("_scaleOffset");
									scaleProperty.vector3Value = Vector3.one;
								}
							}
						}

						objInstanceSerialized.ApplyModifiedProperties();

						EditorGUILayout.EndVertical();
					}

					if(EditorGUI.EndChangeCheck())
					{
						asset.RequestCook(bCheckParametersChanged: true, bAsync: true, bSkipCookCheck: false, bUploadParameters: true);
					}
				}

				HEU_EditorUI.EndSection();
			}
		}
Ejemplo n.º 22
0
		private bool DrawSessionSettings()
		{
			bool bChanged = false;

			HEU_EditorUI.DrawSeparator();

			EditorGUIUtility.labelWidth = 250;
			{
				string oldValue = HEU_PluginSettings.Session_PipeName;
				string newValue = EditorGUILayout.DelayedTextField("Pipe Session Name", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.Session_PipeName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.Session_Localhost;
				string newValue = EditorGUILayout.DelayedTextField("Socket Session Host Name", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.Session_Localhost = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				int oldValue = HEU_PluginSettings.Session_Port;
				int newValue = EditorGUILayout.DelayedIntField("Socket Session Port", oldValue);
				if (oldValue != newValue)
				{
					HEU_PluginSettings.Session_Port = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				float oldValue = HEU_PluginSettings.Session_Timeout;
				float newValue = EditorGUILayout.DelayedFloatField("Session Timeout", oldValue);
				if (oldValue != newValue)
				{
					HEU_PluginSettings.Session_Timeout = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.Session_AutoClose;
				bool newValue = EditorGUILayout.Toggle("Session Auto Close", oldValue);
				if (oldValue != newValue)
				{
					HEU_PluginSettings.Session_AutoClose = newValue;
					bChanged = true;
				}
			}

			EditorGUIUtility.labelWidth = 0;

			return bChanged;
		}
Ejemplo n.º 23
0
		public override void OnInspectorGUI()
		{
			// Try acquiring asset reference in here again due to Undo.
			// Eg. After a delete, Undo requires us to re-acquire references.
			TryAcquiringAsset();

			if (_houdiniAsset == null)
			{
				DrawNoHDAInfo();
				return;
			}

			// Always hook into asset UI callback. This could have got reset on code refresh.
			_houdiniAsset._refreshUIDelegate = RefreshUI;

			serializedObject.Update();
			_houdiniAssetSerializedObject.Update();

			bool guiEnabled = GUI.enabled;

			GUIStyle backgroundStyle = new GUIStyle(GUI.skin.GetStyle("box"));
			RectOffset br = backgroundStyle.margin;
			br.top = 10;
			br.bottom = 6;
			br.left = 4;
			br.right = 4;
			backgroundStyle.margin = br;

			br = backgroundStyle.padding;
			br.top = 8;
			br.bottom = 8;
            br.left = 8;
            br.right = 8;
			backgroundStyle.padding = br;

			using (var hs = new EditorGUILayout.VerticalScope(backgroundStyle))
			{
				HEU_EditorUI.DrawSeparator();

                DrawHeaderSection();

				DrawLicenseInfo();

				bool bSkipDraw = DrawGenerateSection(_houdiniAssetRoot, serializedObject, _houdiniAsset, _houdiniAssetSerializedObject); ;
				if (!bSkipDraw)
				{
					SerializedProperty assetCookStatusProperty = HEU_EditorUtility.GetSerializedProperty(_houdiniAssetSerializedObject, "_cookStatus");
					if (assetCookStatusProperty != null)
					{
						// Track changes to Houdini Asset gameobject
						EditorGUI.BeginChangeCheck();

						DrawEventsSection(_houdiniAsset, _houdiniAssetSerializedObject);

						DrawAssetOptions(_houdiniAsset, _houdiniAssetSerializedObject);

						DrawCurvesSection(_houdiniAsset, _houdiniAssetSerializedObject);

						DrawInputNodesSection(_houdiniAsset, _houdiniAssetSerializedObject);

						DrawTerrainSection(_houdiniAsset, _houdiniAssetSerializedObject);

						// If this is a Curve asset, we don't need to draw parameters as its redundant
						if (_houdiniAsset.AssetType != HEU_HoudiniAsset.HEU_AssetType.TYPE_CURVE)
						{
							DrawParameters(_houdiniAsset.Parameters, ref _parameterEditor);
						}

						DrawInstanceInputs(_houdiniAsset, _houdiniAssetSerializedObject);

						// Check if any changes occurred, and if so, trigger a recook
						if (EditorGUI.EndChangeCheck())
						{
							_houdiniAssetSerializedObject.ApplyModifiedProperties();
							serializedObject.ApplyModifiedProperties();

							// Do recook if values have changed
							if (HEU_PluginSettings.CookingEnabled && _houdiniAsset.AutoCookOnParameterChange && _houdiniAsset.DoesAssetRequireRecook())
							{
								_houdiniAsset.RequestCook(bCheckParametersChanged: true, bAsync: false, bSkipCookCheck: false, bUploadParameters: true);
							}
						}
					}
				}
			}

			GUI.enabled = guiEnabled;
		}
Ejemplo n.º 24
0
		private void DrawTerrainSection(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			int numVolumes = asset.GetVolumeCacheCount();
			if(numVolumes <= 0)
			{
				return;
			}

			HEU_EditorUI.BeginSection();
			{
				SerializedProperty showTerrainProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_showTerrainSection");
				if (showTerrainProperty != null)
				{
					showTerrainProperty.boolValue = HEU_EditorUI.DrawFoldOut(showTerrainProperty.boolValue, "TERRAIN");
					if (showTerrainProperty.boolValue)
					{
						// Draw each volume layer
						List<HEU_VolumeCache> volumeCaches = asset.GetVolumeCaches();
						int numCaches = volumeCaches.Count;
						for (int i = 0; i < numCaches; ++i)
						{
							SerializedObject cacheObjectSerialized = new SerializedObject(volumeCaches[i]);
							bool bChanged = false;

							SerializedProperty layersProperty = cacheObjectSerialized.FindProperty("_layers");
							if (layersProperty == null || layersProperty.arraySize == 0)
							{
								continue;
							}

							string heading = string.Format("{0}-{1}:", volumeCaches[i].ObjectName, volumeCaches[i].GeoName);

							if (HEU_EditorUI.DrawFoldOutSerializedProperty(HEU_EditorUtility.GetSerializedProperty(cacheObjectSerialized, "_uiExpanded"), heading, ref bChanged))
							{
								EditorGUI.indentLevel++;

								int numlayers = layersProperty.arraySize;
								for (int j = 0; j < numlayers; ++j)
								{
									SerializedProperty layerProperty = layersProperty.GetArrayElementAtIndex(j);
									if (layerProperty == null)
									{
										continue;
									}

									string layerName = string.Format("Layer: {0}", layerProperty.FindPropertyRelative("_layerName").stringValue);

									SerializedProperty uiExpandedProperty = layerProperty.FindPropertyRelative("_uiExpanded");
									bool bExpanded = uiExpandedProperty != null ? uiExpandedProperty.boolValue : true;
									bool bNewExpanded = HEU_EditorUI.DrawFoldOut(bExpanded, layerName);
									if (uiExpandedProperty != null && bExpanded != bNewExpanded)
									{
										bChanged = true;
										uiExpandedProperty.boolValue = bNewExpanded;
									}

									if (!bNewExpanded)
									{
										continue;
									}

									if (HEU_EditorUtility.EditorDrawFloatSliderProperty(layerProperty, "_strength", "Strength", "Amount to multiply the layer values by on import."))
									{
										bChanged = true;
									}

									SerializedProperty overrideProperty = layerProperty.FindPropertyRelative("_overrides");

									SerializedProperty textureProperty = layerProperty.FindPropertyRelative("_diffuseTexture");
									if (textureProperty != null)
									{
										Object textureObject = textureProperty.objectReferenceValue;
										EditorGUILayout.PropertyField(textureProperty, new GUIContent("Diffuse Texture", "Difuse texture used by terrain layer."));
										if (textureObject != textureProperty.objectReferenceValue)
										{
											SetVolumeLayerPropertyOverride(overrideProperty, HEU_VolumeLayer.Overrides.Diffuse);
											bChanged = true;
										}

										HEU_EditorUI.DrawSeparator();
									}

#if UNITY_2018_3_OR_NEWER
									SerializedProperty maskTextureProperty = layerProperty.FindPropertyRelative("_maskTexture");
									if (maskTextureProperty != null)
									{
										Object textureObject = maskTextureProperty.objectReferenceValue;
										EditorGUILayout.PropertyField(maskTextureProperty, new GUIContent("Mask Texture", "The mask map texture used by the terrain layer."));
										if (textureObject != maskTextureProperty.objectReferenceValue)
										{
											SetVolumeLayerPropertyOverride(overrideProperty, HEU_VolumeLayer.Overrides.Mask);
											bChanged = true;
										}

										HEU_EditorUI.DrawSeparator();
									}
#endif

									SerializedProperty normalProperty = layerProperty.FindPropertyRelative("_normalTexture");
									if (normalProperty != null)
									{
										Object normalObject = normalProperty.objectReferenceValue;
										EditorGUILayout.PropertyField(normalProperty, new GUIContent("NormalMap", "Normal map of the splat applied to the Terrain."));
										if (normalObject != normalProperty.objectReferenceValue)
										{
											SetVolumeLayerPropertyOverride(overrideProperty, HEU_VolumeLayer.Overrides.Normal);
											bChanged = true;
										}

										HEU_EditorUI.DrawSeparator();
									}

#if UNITY_2018_3_OR_NEWER
									if (HEU_EditorUtility.EditorDrawFloatSliderProperty(layerProperty, "_normalScale", "Normal Scale", "The normal scale value of the splat layer."))
									{
										SetVolumeLayerPropertyOverride(overrideProperty, HEU_VolumeLayer.Overrides.NormalScale);
										bChanged = true;
									}
#endif

									if (HEU_EditorUtility.EditorDrawFloatSliderProperty(layerProperty, "_metallic", "Metallic", "The metallic value of the splat layer."))
									{
										SetVolumeLayerPropertyOverride(overrideProperty, HEU_VolumeLayer.Overrides.Metallic);
										bChanged = true;
									}

									if (HEU_EditorUtility.EditorDrawFloatSliderProperty(layerProperty, "_smoothness", "Smoothness", "The smoothness value of the splat layer when the main texture has no alpha channel."))
									{
										SetVolumeLayerPropertyOverride(overrideProperty, HEU_VolumeLayer.Overrides.Smoothness);
										bChanged = true;
									}

#if UNITY_2018_3_OR_NEWER
									SerializedProperty specularProperty = layerProperty.FindPropertyRelative("_specularColor");
									if (specularProperty != null)
									{
										Color specColor = specularProperty.colorValue;
										EditorGUILayout.PropertyField(specularProperty, new GUIContent("Specular", "Specular color"));
										if (specularProperty.colorValue != specColor)
										{
											SetVolumeLayerPropertyOverride(overrideProperty, HEU_VolumeLayer.Overrides.Specular);

											bChanged = true;
										}
									}
#endif

									if (HEU_EditorUtility.EditorDrawVector2RelativeProperty(layerProperty, "_tileSize", "Tile Size (W, H)", "Size of the tile used in the texture of the SplatPrototype."))
									{
										SetVolumeLayerPropertyOverride(overrideProperty, HEU_VolumeLayer.Overrides.TileSize);
										bChanged = true;
									}

									if (HEU_EditorUtility.EditorDrawVector2RelativeProperty(layerProperty, "_tileOffset", "Tile Offset (X, Y)", "Offset of the tile texture of the SplatPrototype."))
									{
										SetVolumeLayerPropertyOverride(overrideProperty, HEU_VolumeLayer.Overrides.TileOffset);
										bChanged = true;
									}

									HEU_EditorUI.DrawSeparator();
								}

								EditorGUI.indentLevel--;
							}

							if(bChanged)
							{
								SerializedProperty dirtyProperty = cacheObjectSerialized.FindProperty("_isDirty");
								if (dirtyProperty != null)
								{
									dirtyProperty.boolValue = true;
								}

								cacheObjectSerialized.ApplyModifiedProperties();
							}
						}
					}
				}
			}
			HEU_EditorUI.EndSection();

			HEU_EditorUI.DrawSeparator();
		}
		public void OnGUI()
		{
			if (!_initializedUI)
			{
				// Creating of UI elements must happen in OnGUI
				InitializeUIElements();
			}

			bool bChanged = false;

			Color originalBGColor = GUI.backgroundColor;

			bool bRequiresLoad = !HEU_ShelfTools.AreShelvesLoaded();
			if(!bRequiresLoad)
			{
				// Sanity check that textures are still valid. When scene changes, these get invalidated.
				if (_guiContents != null && _guiContents.Length > 0)
				{
					bRequiresLoad = (_guiContents[0].image == null);
				}
			}
			
			if(bRequiresLoad)
			{
				LoadShelves();
			}

			int numTools = 0;

			using (new EditorGUILayout.VerticalScope())
			{
				using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
				{
					if (HEU_ShelfTools.AreShelvesLoaded())
					{
						int currentShelfIndex = HEU_ShelfTools.GetCurrentShelfIndex();

						HEU_Shelf shelf = null;

						using (new EditorGUILayout.HorizontalScope())
						{
							GUILayout.FlexibleSpace();

							if (GUILayout.Button(_addButton, _buttonStyle, GUILayout.MaxWidth(_buttonWidth), GUILayout.MaxHeight(_buttonHeight)))
							{
								string newShelfPath = UnityEditor.EditorUtility.OpenFolderPanel("Add Shelf Folder", "", "");
								if (!string.IsNullOrEmpty(newShelfPath) && HEU_Platform.DoesDirectoryExist(newShelfPath))
								{
									AddNewShelfWindow(newShelfPath);
									bChanged = true;
								}
							}
						}

						using (new EditorGUILayout.HorizontalScope())
						{
							GUILayout.Label("Active Shelf");

							int newShelfIndex = EditorGUILayout.Popup(currentShelfIndex, _shelfNames, _popupStyle);
							if (currentShelfIndex != newShelfIndex)
							{
								// Change shelf
								currentShelfIndex = newShelfIndex;
								HEU_ShelfTools.SetCurrentShelf(currentShelfIndex);
								SelectShelf(currentShelfIndex);
							}

							shelf = HEU_ShelfTools.GetShelf(currentShelfIndex);
							numTools = shelf._tools.Count;

							using (new EditorGUI.DisabledGroupScope(shelf._defaultShelf))
							{
								if (GUILayout.Button(_removeButton, _buttonStyle, GUILayout.MaxWidth(_buttonWidth)))
								{
									HEU_ShelfTools.RemoveShelf(currentShelfIndex);

									HEU_ShelfTools.SaveShelf();
									HEU_ShelfTools.SetReloadShelves();
									bChanged = true;
								}
							}
						}


						HEU_EditorUI.DrawSeparator();

						if (!bChanged)
						{
							using (EditorGUILayout.ScrollViewScope scroll = new EditorGUILayout.ScrollViewScope(_toolButtonScrollPos))
							{
								if (numTools > 0)
								{
									int numXElements = numTools < _toolGridXElements ? numTools : _toolGridXElements;

									_selectedToolIndex = GUILayout.SelectionGrid(_selectedToolIndex, _guiContents, numXElements, _toolGridStyle);
								}
								else
								{
									EditorGUILayout.LabelField("No tools found!");
								}

								_toolButtonScrollPos = scroll.scrollPosition;
							}
						}
					}
				}
				
				bool bValidSelection = (_selectedToolIndex >= 0 && _selectedToolIndex < numTools);
				using (new EditorGUI.DisabledGroupScope(!bValidSelection))
				{
					if(!bValidSelection)
					{
						_applyButton.text = "Select a Tool!";
					}
					else
					{
						GameObject[] selectedObjects = HEU_EditorUtility.GetSelectedObjects();
						if(selectedObjects.Length == 0)
						{
							_applyButton.text = "Create Tool (no input selected)!";
						}
						else
						{
							_applyButton.text = "Create Tool (selected objects as inputs)!";
						}
					}

					if (GUILayout.Button(_applyButton, _buttonStyle, GUILayout.MaxHeight(_buttonHeight)))
					{
						ProcessUserSelection(_selectedToolIndex);
					}
				}
			}
		}
		private void DrawTerrainSection(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			int numVolumes = asset.GetVolumeCacheCount();
			if(numVolumes <= 0)
			{
				return;
			}

			HEU_EditorUI.BeginSection();
			{
				SerializedProperty showTerrainProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_showTerrainSection");
				if (showTerrainProperty != null)
				{
					showTerrainProperty.boolValue = HEU_EditorUI.DrawFoldOut(showTerrainProperty.boolValue, "TERRAIN");
					if (showTerrainProperty.boolValue)
					{
						// Draw each volume layer
						List<HEU_VolumeCache> volumeCaches = asset.GetVolumeCaches();
						int numCaches = volumeCaches.Count;
						for (int i = 0; i < numCaches; ++i)
						{
							SerializedObject cacheObjectSerialized = new SerializedObject(volumeCaches[i]);
							bool bChanged = false;
							bool bStrengthChanged = false;

							SerializedProperty layersProperty = cacheObjectSerialized.FindProperty("_layers");
							if (layersProperty == null || layersProperty.arraySize == 0)
							{
								continue;
							}

							string heading = string.Format("{0}-{1}:", volumeCaches[i].ObjectName, volumeCaches[i].GeoName);

							if (HEU_EditorUI.DrawFoldOutSerializedProperty(HEU_EditorUtility.GetSerializedProperty(cacheObjectSerialized, "_uiExpanded"), heading, ref bChanged))
							{
								EditorGUI.indentLevel++;

								int numlayers = layersProperty.arraySize;
								for (int j = 0; j < numlayers; ++j)
								{
									SerializedProperty layerProperty = layersProperty.GetArrayElementAtIndex(j);
									if (layerProperty == null)
									{
										continue;
									}

									// Skipping "height" layer on UI since its treated as Houdini-specific layer
									string layerName = layerProperty.FindPropertyRelative("_layerName").stringValue;
									if (layerName.Equals(HEU_Defines.HAPI_HEIGHTFIELD_LAYERNAME_HEIGHT))
									{
										continue;
									}
									layerName = string.Format("Layer: {0}", layerName);

									SerializedProperty uiExpandedProperty = layerProperty.FindPropertyRelative("_uiExpanded");
									bool bExpanded = uiExpandedProperty != null ? uiExpandedProperty.boolValue : true;
									bool bNewExpanded = HEU_EditorUI.DrawFoldOut(bExpanded, layerName);
									if (uiExpandedProperty != null && bExpanded != bNewExpanded)
									{
										bChanged = true;
										uiExpandedProperty.boolValue = bNewExpanded;
									}

									if (!bNewExpanded)
									{
										continue;
									}

									if (HEU_EditorUtility.EditorDrawFloatSliderProperty(layerProperty, "_strength", "Strength", "Amount to multiply the layer values by on import."))
									{
										bStrengthChanged = true;
									}

									HEU_EditorUI.DrawSeparator();
								}

								EditorGUI.indentLevel--;
							}

							if (bStrengthChanged)
							{
								SerializedProperty dirtyProperty = cacheObjectSerialized.FindProperty("_isDirty");
								if (dirtyProperty != null)
								{
									dirtyProperty.boolValue = true;
									bChanged = true;
								}
							}

							if(bChanged)
							{
								cacheObjectSerialized.ApplyModifiedProperties();
							}
						}
					}
				}
			}
			HEU_EditorUI.EndSection();

			HEU_EditorUI.DrawSeparator();
		}
Ejemplo n.º 27
0
		private void DrawCurvesSection(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			if (asset.GetEditableCurveCount() <= 0)
			{
				return;
			}

			GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
			buttonStyle.fontSize = 11;
			buttonStyle.alignment = TextAnchor.MiddleCenter;
			buttonStyle.fixedHeight = 24;
			buttonStyle.margin.left = 34;

			HEU_EditorUI.BeginSection();
			{
				SerializedProperty showCurvesProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_showCurvesSection");
				if (showCurvesProperty != null)
				{
					showCurvesProperty.boolValue = HEU_EditorUI.DrawFoldOut(showCurvesProperty.boolValue, "CURVES");
					if (showCurvesProperty.boolValue)
					{
						SerializedProperty curveEditorProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveEditorEnabled");
						if (curveEditorProperty != null)
						{
							EditorGUILayout.PropertyField(curveEditorProperty);
						}

						HEU_EditorUI.DrawHeadingLabel("Collision Settings");
						EditorGUI.indentLevel++;

						string projectLabel = "Project Curves To ";
						List<HEU_Curve> curves = asset.GetCurves();

						SerializedProperty curveCollisionProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveDrawCollision");
						if (curveCollisionProperty != null)
						{
							EditorGUILayout.PropertyField(curveCollisionProperty, new GUIContent("Collision Type"));
							if (curveCollisionProperty.enumValueIndex == (int)HEU_Curve.CurveDrawCollision.COLLIDERS)
							{
								HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveDrawColliders", label: "Colliders");
								projectLabel += "Colliders";
							}
							else if (curveCollisionProperty.enumValueIndex == (int)HEU_Curve.CurveDrawCollision.LAYERMASK)
							{
								HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveDrawLayerMask", label: "Layer Mask");
								projectLabel += "Layer";
							}

							HEU_EditorUI.DrawSeparator();

							EditorGUI.indentLevel--;
							HEU_EditorUI.DrawHeadingLabel("Projection Settings");
							EditorGUI.indentLevel++;

							HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveProjectDirection", label: "Project Direction", tooltip: "The ray cast direction for projecting the curve points.");
							HEU_EditorUtility.EditorDrawFloatProperty(assetObject, "_curveProjectMaxDistance", label: "Project Max Distance", tooltip: "The maximum ray cast distance for projecting the curve points.");

							_projectCurvePointsButton.text = projectLabel;
							if (GUILayout.Button(_projectCurvePointsButton, buttonStyle, GUILayout.MaxWidth(180)))
							{
								SerializedProperty projectDirProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveProjectDirection");
								SerializedProperty maxDistanceProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveProjectMaxDistance");

								Vector3 projectDir = projectDirProperty != null ? projectDirProperty.vector3Value : Vector3.down;
								float maxDistance = maxDistanceProperty != null ? maxDistanceProperty.floatValue : 0;

								for (int i = 0; i < curves.Count; ++i)
								{
									curves[i].ProjectToColliders(asset, projectDir, maxDistance);
								}
							}
						}

						EditorGUI.indentLevel--;

						HEU_EditorUI.DrawSeparator();

						for (int i = 0; i < curves.Count; ++i)
						{
							if (curves[i].Parameters != null)
							{
								DrawParameters(curves[i].Parameters, ref _curveParameterEditor);
							}
						}
					}
				}
			}
			HEU_EditorUI.EndSection();

			HEU_EditorUI.DrawSeparator();
		}
Ejemplo n.º 28
0
		private bool DrawAdvancedSettings()
		{
			bool bChanged = false;

			GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
			labelStyle.normal.textColor = HEU_EditorUI.GetUISafeTextColorYellow();
			EditorGUILayout.LabelField("Warning: Changing these values from default might result in HDAs not loading properly!", labelStyle, GUILayout.MinHeight(30));
			HEU_EditorUI.DrawSeparator();

			EditorGUIUtility.labelWidth = 250;
			{
				string oldValue = HEU_PluginSettings.HDAData_Name;
				string newValue = EditorGUILayout.DelayedTextField("HDA Data GameObject Name", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.HDAData_Name = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.EditorOnly_Tag;
				string newValue = EditorGUILayout.DelayedTextField("HDA Data GameObject Tag", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.EditorOnly_Tag = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.CollisionGroupName;
				string newValue = EditorGUILayout.DelayedTextField("Collision Group", oldValue);
				if(oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.CollisionGroupName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.RenderedCollisionGroupName;
				string newValue = EditorGUILayout.DelayedTextField("Rendered Collision Group", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.RenderedCollisionGroupName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.UnityMaterialAttribName;
				string newValue = EditorGUILayout.DelayedTextField("Unity Material Attribute", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.UnityMaterialAttribName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.UnitySubMaterialAttribName;
				string newValue = EditorGUILayout.DelayedTextField("Unity Substance Material Attribute", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.UnitySubMaterialAttribName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.UnityTagAttributeName;
				string newValue = EditorGUILayout.DelayedTextField("Unity Tag Attribute", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.UnityTagAttributeName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.UnityScriptAttributeName;
				string newValue = EditorGUILayout.DelayedTextField("Unity Script Attribute", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.UnityScriptAttributeName = newValue;
					bChanged = true;
				}
			}

			EditorGUIUtility.labelWidth = 0;

			return bChanged;
		}
	/// <summary>
	/// Draw the given asset's input instances.
	/// Caches initially, then draws in paginized format.
	/// </summary>
	/// <param name="asset">Asset's input instances to draw</param>
	/// <param name="assetObject">Serialized object of assset</param>
	public void DrawInstanceInputs(HEU_HoudiniAsset asset, SerializedObject assetObject)
	{
	    if (!_populated)
	    {
		// Create cache
		PopulateInstanceInputCache(asset, assetObject);
	    }

	    if (_instanceObjects.Count == 0)
	    {
		//Debug.Log("No instance objects");
		return;
	    }

	    HEU_EditorUI.DrawSeparator();

	    int numObjInstances = _instanceObjects.Count;

	    // Display input section if at least have 1 input field
	    if (numObjInstances > 0)
	    {
		HEU_EditorUI.BeginSection();

		EditorGUI.BeginChangeCheck();

		_showInstanceInputsProperty.boolValue = HEU_EditorUI.DrawFoldOut
			(_showInstanceInputsProperty.boolValue, "INSTANCE INPUTS");

		if (EditorGUI.EndChangeCheck())
		{
		    // Only apply change to the UI object so don't need to cook entire asset
		    _serializedObject.ApplyModifiedProperties();
		}

		if (_showInstanceInputsProperty.boolValue)
		{
		    EditorGUI.BeginChangeCheck();

		    // Number to display per page
		    EditorGUILayout.DelayedIntField(_numInputsToShowProperty, new GUIContent("Display Per Page"));

		    int numInputsToShow = Mathf.Clamp(_numInputsToShowProperty.intValue, 1, numObjInstances);
		    _numInputsToShowProperty.intValue = numInputsToShow;

		    int inputsPageIndex = _inputsPageIndexProperty.intValue;

		    int totalPages = numObjInstances / numInputsToShow;

		    using (new GUILayout.HorizontalScope())
		    {
			EditorGUILayout.DelayedIntField(_inputsPageIndexProperty, new GUIContent("Page"));

			// Current page
			inputsPageIndex = Mathf.Clamp(_inputsPageIndexProperty.intValue, 0, totalPages - 1);

			// Previous page
			EditorGUI.BeginDisabledGroup(inputsPageIndex <= 0);
			if (GUILayout.Button("<<"))
			{
			    inputsPageIndex--;
			}
			EditorGUI.EndDisabledGroup();

			// Next page
			EditorGUI.BeginDisabledGroup(inputsPageIndex >= (totalPages - 1));
			if (GUILayout.Button(">>"))
			{
			    inputsPageIndex++;
			}
			EditorGUI.EndDisabledGroup();

			_inputsPageIndexProperty.intValue = inputsPageIndex;
		    }

		    inputsPageIndex = inputsPageIndex < totalPages ? inputsPageIndex : totalPages - 1;

		    int startIndex = inputsPageIndex * numInputsToShow;
		    int validNumInputs = numInputsToShow <= numObjInstances ? numInputsToShow : numObjInstances;

		    if (EditorGUI.EndChangeCheck())
		    {
			// Only apply change to the UI object so don't need to cook entire asset
			_serializedObject.ApplyModifiedProperties();
		    }

		    EditorGUI.BeginChangeCheck();

		    // Draw instanced input info for current page
		    for (int i = 0; i < validNumInputs; ++i)
		    {
			EditorGUILayout.BeginVertical();

			int currentIndex = startIndex + i;

			if (_instanceObjects[currentIndex]._instancedInputsProperty != null)
			{
			    int inputCount = _instanceObjects[currentIndex]._instancedInputsProperty.arraySize;
			    EditorGUILayout.PropertyField(_instanceObjects[currentIndex]._instancedInputsProperty,
				    new GUIContent(_instanceObjects[currentIndex]._inputName), true);

			    // When input size increases, Unity creates default values for HEU_InstancedInput which results in
			    // zero value for scale offset. This fixes it up.
			    int newInputCount = _instanceObjects[currentIndex]._instancedInputsProperty.arraySize;
			    if (inputCount < newInputCount)
			    {
				for (int inputIndex = inputCount; inputIndex < newInputCount; ++inputIndex)
				{
				    SerializedProperty scaleProperty = _instanceObjects[currentIndex]._instancedInputsProperty.GetArrayElementAtIndex(inputIndex).FindPropertyRelative("_scaleOffset");
				    scaleProperty.vector3Value = Vector3.one;
				}
			    }
			}

			_instanceObjects[currentIndex]._objInstanceSerialized.ApplyModifiedProperties();

			EditorGUILayout.EndVertical();
		    }

		    if (EditorGUI.EndChangeCheck())
		    {
			asset.RequestCook(bCheckParametersChanged: true, bAsync: true, bSkipCookCheck: false, bUploadParameters: true);
		    }
		}

		HEU_EditorUI.EndSection();
	    }
	}
Ejemplo n.º 30
0
		public override void OnInspectorGUI()
		{
			if (_geoSync == null)
			{
				AcquireTarget();
			}

			using (new EditorGUILayout.VerticalScope())
			{
				bool bSyncing = _geoSync.IsSyncing;

				EditorGUILayout.LabelField(_fileLabelContent);

				using (new EditorGUILayout.HorizontalScope())
				{
					_geoSync._filePath = EditorGUILayout.DelayedTextField(_geoSync._filePath);

					// TODO: add field for output cache directory

					GUIStyle buttonStyle = HEU_EditorUI.GetNewButtonStyle_MarginPadding(0, 0);
					if (GUILayout.Button("...", buttonStyle, GUILayout.Width(30), GUILayout.Height(18)))
					{
						string filePattern = "*.bgeo;*.bgeo.sc";
						_geoSync._filePath = EditorUtility.OpenFilePanel("Select File", _geoSync._filePath, filePattern);
					}
				}

				HEU_EditorUI.DrawSeparator();

				if (bSyncing)
				{
					EditorGUILayout.LabelField(_statusSyncContent);

					if (GUILayout.Button(_stopContent))
					{
						_geoSync.StopSync();
					}
				}
				else
				{
					EditorGUILayout.LabelField(_statusIdleContent);

					using (new EditorGUILayout.HorizontalScope())
					{
						bool bLoaded = _geoSync.IsLoaded();

						if (GUILayout.Button(_syncContent))
						{
							_geoSync.StartSync();
						}

						//GUILayout.FlexibleSpace();

						using (new EditorGUI.DisabledScope(!bLoaded))
						{
							if (GUILayout.Button(_unloadContent))
							{
								_geoSync.Unload();
							}
						}
					}
				}

				if (!string.IsNullOrEmpty(_geoSync._logStr))
				{
					EditorGUILayout.LabelField("Log: " + _geoSync._logStr);
				}
			}
		}