Ejemplo n.º 1
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.º 2
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();

	    string msg = "Houdini Engine Asset Error\n" +
		    "No HEU_HoudiniAsset found!";
	    if (_houdiniAsset == null || !_houdiniAsset.IsValidForInteraction(ref msg))
	    {
		DrawHDAUIMessage(msg);
		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;

	    using (new EditorGUILayout.VerticalScope())
	    {
		DrawHeaderSection();

		DrawLicenseInfo();

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

		// Track changes to Houdini Asset gameobject
		EditorGUI.BeginChangeCheck();

		bool bSkipAutoCook = DrawGenerateSection(_houdiniAssetRoot, serializedObject, _houdiniAsset, _houdiniAssetSerializedObject, ref pendingBuildAction);
		if (!bSkipAutoCook)
		{
		    SerializedProperty assetCookStatusProperty = HEU_EditorUtility.GetSerializedProperty(_houdiniAssetSerializedObject, "_cookStatus");
		    if (assetCookStatusProperty != null)
		    {
			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);
			    HEU_EditorUI.DrawSeparator();
			}

			DrawInstanceInputs(_houdiniAsset, _houdiniAssetSerializedObject);

			bSkipAutoCook = DrawBakeSection(_houdiniAssetRoot, serializedObject, _houdiniAsset, _houdiniAssetSerializedObject, ref pendingBuildAction);

			DrawAssetOptions(_houdiniAsset, _houdiniAssetSerializedObject);

			DrawEventsSection(_houdiniAsset, _houdiniAssetSerializedObject);
		    }
		}

		ProcessPendingBuildAction(pendingBuildAction, pendingBuildProperty,
		    _houdiniAssetRoot, serializedObject, _houdiniAsset, _houdiniAssetSerializedObject);

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

		    if (!bSkipAutoCook)
		    {
			// Do automatic cook 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;
	}