Ejemplo n.º 1
0
		// If enabled, show only the edit node's geometry.
		private void UpdateShowOnlyEditGeometry()
		{
			if (_asset != null && _toolsInfoSerializedObject != null)
			{
				SerializedProperty showProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_showOnlyEditGeometry");
				if(showProperty != null)
				{
					if(showProperty.boolValue)
					{
						if (_selectedAttributesStore != null)
						{
							// Hide the asset geo and its colliders
							_asset.HideAllGeometry();
							_asset.DisableAllColliders();
						}
					}
					else
					{
						// Show asset geo based on its internal state
						_asset.CalculateVisibility();
						_asset.CalculateColliderState();
					}
				}
			}
		}
Ejemplo n.º 2
0
		private void ClearCache()
		{
			if (_toolsInfoSerializedObject != null)
			{
				SerializedProperty isPaintingProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_isPainting");
				PaintingFinished(isPaintingProperty);
			}

			_selectedAttributesStore = null;
			_selectedAttributeData = null;

			_attributesStores.Clear();
			_serializedAttributesStoresCache.Clear();

			if(_editPointBoxMaterial != null)
			{
				HEU_MaterialFactory.DestroyNonAssetMaterial(_editPointBoxMaterial, false);
				_editPointBoxMaterial = null;
			}

			DestroyEditPointBoxMesh();

			_dragMouseDown = false;

			_asset = null;

			_toolsInfo = null;
		}
Ejemplo n.º 3
0
	private static void ProcessPendingBuildAction(
	    HEU_HoudiniAsset.AssetBuildAction pendingBuildAction,
	    SerializedProperty pendingBuildProperty,
	    HEU_HoudiniAssetRoot assetRoot, 
	    SerializedObject assetRootSerializedObject, 
	    HEU_HoudiniAsset asset, 
	    SerializedObject assetObject)
	{
	    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;
		    }

		    // But we do want to always upload input geometry on user hitting Recook expliclity
		    SerializedProperty forceUploadInputs = HEU_EditorUtility.GetSerializedProperty(assetObject, "_forceUploadInputs");
		    if (forceUploadInputs != null)
		    {
			forceUploadInputs.boolValue = true;
		    }
		}
	    }
	}
Ejemplo n.º 4
0
        /// <summary>
        /// Populate the UI cache for the given input node
        /// </summary>
        /// <param name="inputNode"></param>
        public static void PopulateCache(HEU_InputNode inputNode)
        {
            if (inputNode._uiCache == null)
            {
                inputNode._uiCache = new HEU_InputNodeUICache();

                inputNode._uiCache._inputNodeSerializedObject = new SerializedObject(inputNode);

                inputNode._uiCache._inputObjectTypeProperty    = HEU_EditorUtility.GetSerializedProperty(inputNode._uiCache._inputNodeSerializedObject, "_inputObjectType");
                inputNode._uiCache._keepWorldTransformProperty = HEU_EditorUtility.GetSerializedProperty(inputNode._uiCache._inputNodeSerializedObject, "_keepWorldTransform");
                inputNode._uiCache._packBeforeMergeProperty    = HEU_EditorUtility.GetSerializedProperty(inputNode._uiCache._inputNodeSerializedObject, "_packGeometryBeforeMerging");

                inputNode._uiCache._inputObjectsProperty = HEU_EditorUtility.GetSerializedProperty(inputNode._uiCache._inputNodeSerializedObject, "_inputObjects");

                inputNode._uiCache._inputAssetProperty = HEU_EditorUtility.GetSerializedProperty(inputNode._uiCache._inputNodeSerializedObject, "_inputAsset");

                int inputCount = inputNode._uiCache._inputObjectsProperty.arraySize;
                for (int i = 0; i < inputCount; ++i)
                {
                    SerializedProperty inputObjectProperty = inputNode._uiCache._inputObjectsProperty.GetArrayElementAtIndex(i);

                    HEU_InputNodeUICache.HEU_InputObjectUICache objectCache = new HEU_InputNodeUICache.HEU_InputObjectUICache();

                    objectCache._gameObjectProperty = inputObjectProperty.FindPropertyRelative("_gameObject");

                    objectCache._transformOffsetProperty = inputObjectProperty.FindPropertyRelative("_useTransformOffset");

                    objectCache._translateProperty = inputObjectProperty.FindPropertyRelative("_translateOffset");
                    objectCache._rotateProperty    = inputObjectProperty.FindPropertyRelative("_rotateOffset");
                    objectCache._scaleProperty     = inputObjectProperty.FindPropertyRelative("_scaleOffset");

                    inputNode._uiCache._inputObjectCache.Add(objectCache);
                }
            }
        }
Ejemplo n.º 5
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.º 6
0
	private void DrawPaintModeInfo()
	{
	    bool bFillInvoked = false;

	    float uiWidth = _editorUIRect.width * _infoPanelSettingsWidth;

	    using (var verticalSpace = new GUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.MaxWidth(uiWidth)))
	    {
		// Attribute Selection, and paint values

		DrawAttributeSelection();

		DrawPaintAttributeValues();

		SerializedProperty paintMeshProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintMeshVisiblity");
		if (paintMeshProperty != null)
		{
		    int currentVisibility = paintMeshProperty.enumValueIndex;
		    EditorGUILayout.PropertyField(paintMeshProperty, new GUIContent("Paint Mesh Visiblity"));
		    if (currentVisibility != paintMeshProperty.enumValueIndex)
		    {
			ChangePaintMeshVisiblity((HEU_ToolsInfo.PaintMeshVisibility)paintMeshProperty.enumValueIndex);
		    }
		}
	    }

	    using (var verticalSpace = new GUILayout.VerticalScope(EditorStyles.helpBox))
	    {
		// Tool Settings

		HEU_EditorUtility.EditorDrawBoolProperty(_toolsInfoSerializedObject, "_liveUpdate", _cookOnMouseReleaseLabel, "Auto-cook on mouse release when painting.");

		HEU_EditorUtility.EditorDrawFloatProperty(_toolsInfoSerializedObject, "_paintBrushSize", _brushSizeLabel, "Change brush size via Shift + drag or Shift + mouse scroll.");
		HEU_EditorUtility.EditorDrawFloatProperty(_toolsInfoSerializedObject, "_paintBrushOpacity", _brushOpacityLabel, "Blending factor when merging source and destination colors.");

		HEU_EditorUtility.EditorDrawSerializedProperty(_toolsInfoSerializedObject, "_paintMergeMode", _brushMergeMode, "How paint color is applied to surface.");

		HEU_EditorUtility.EditorDrawSerializedProperty(_toolsInfoSerializedObject, "_brushHandleColor", _brushHandleColor, "Color of the brush handle in Scene.");

		bFillInvoked = GUILayout.Button(_paintFillLabel, GUILayout.Height(_buttonHeight));
	    }

	    if (_selectedAttributesStore != null)
	    {
		if (bFillInvoked)
		{
		    HEU_ToolsInfo toolsInfo = _toolsInfoSerializedObject.targetObject as HEU_ToolsInfo;
		    _selectedAttributesStore.FillAttribute(_selectedAttributeData, toolsInfo);

		    _GUIChanged = true;
		}
	    }
	}
Ejemplo n.º 7
0
		private static HEU_HoudiniAsset.AssetCookStatus GetCookStatusFromSerializedAsset(SerializedObject assetObject)
		{
			HEU_HoudiniAsset.AssetCookStatus cookStatus = HEU_HoudiniAsset.AssetCookStatus.NONE;

			SerializedProperty cookStatusProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_cookStatus");
			if (cookStatusProperty != null)
			{
				cookStatus = (HEU_HoudiniAsset.AssetCookStatus)cookStatusProperty.enumValueIndex;
			}

			return cookStatus;
		}
Ejemplo n.º 8
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.º 9
0
		private void DrawEditModeInfo()
		{
			float uiWidth = _editorUIRect.width * _infoPanelSettingsWidth;

			using (var verticalSpace = new GUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.MaxWidth(uiWidth)))
			{
				// Attribute Selection and editing values

				DrawAttributeSelection();

				DrawEditAttributeValues();
			}

			using (var verticalSpace = new GUILayout.VerticalScope(EditorStyles.helpBox))
			{
				// Tool Settings

				EditorGUI.BeginChangeCheck();

				SerializedProperty showGeoProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_showOnlyEditGeometry");
				if (showGeoProperty != null)
				{
					bool bOldValue = showGeoProperty.boolValue;
					EditorGUILayout.PropertyField(showGeoProperty, new GUIContent(_showOnlyEditGeoLabel, "Show only this edit node's geometry."));
					if (bOldValue != showGeoProperty.boolValue)
					{
						UpdateShowOnlyEditGeometry();
					}
				}

				HEU_EditorUtility.EditorDrawFloatProperty(_toolsInfoSerializedObject, "_editPointBoxSize", _pointSizeLabel, "Change size of the point box visualization.");

				HEU_EditorUtility.EditorDrawSerializedProperty(_toolsInfoSerializedObject, "_editPointBoxUnselectedColor", _unselectedPtColorLabel);

				HEU_EditorUtility.EditorDrawSerializedProperty(_toolsInfoSerializedObject, "_editPointBoxSelectedColor", _selectedPtColorLabel);

				EditorGUILayout.LabelField(_selectedPtsLabel + _editPointsSelectedIndices.Count);

				if (GUILayout.Button(_selectAllPtsLabel, GUILayout.Height(_buttonHeight)))
				{
					SelectAllPoints();
				}

				if (EditorGUI.EndChangeCheck())
				{
					GenerateEditPointBoxNewMesh();
				}
			}
		}
Ejemplo n.º 10
0
		private float UpdateBrushSize(float radius)
		{
			if(radius < 0.01f)
			{
				radius = 0.01f;
			}

			SerializedProperty property = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintBrushSize");
			if(property != null && (Mathf.Abs(property.floatValue - radius) >= float.Epsilon))
			{
				property.floatValue = radius;
			}

			return radius;
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Initialially populates the instance input cache.
		/// Should be called after every cook, or when selection changes.
		/// </summary>
		/// <param name="asset">HEU_HoudiniAsset object</param>
		/// <param name="assetObject">Serialized HEU_HoudiniAsset</param>
		private void PopulateInstanceInputCache(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			//Debug.Log("PopulateInstanceInputCache");

			if (asset.InstanceInputUIState == null)
			{
				// This could be null due to upgrade of the plugin with an asset that was
				// instatiated from an older version of the plugin. Just create it now.
				asset.InstanceInputUIState = ScriptableObject.CreateInstance<HEU_InstanceInputUIState>();
			}

			// Get list of object instance infos in asset
			List<HEU_ObjectInstanceInfo> objInstanceInfos = new List<HEU_ObjectInstanceInfo>();
			asset.PopulateObjectInstanceInfos(objInstanceInfos);

			_populated = true;

			int numObjInstances = objInstanceInfos.Count;
			if (numObjInstances <= 0)
			{
				// No instances means nothing to show, so no need to create cache
				return;
			}

			_serializedObject = new SerializedObject(asset.InstanceInputUIState);

			_showInstanceInputsProperty = _serializedObject.FindProperty("_showInstanceInputs");

			_numInputsToShowProperty = _serializedObject.FindProperty("_numInputsToShowUI");

			_inputsPageIndexProperty = _serializedObject.FindProperty("_inputsPageIndexUI");

			// Create cache for each object instance info
			for (int i = 0; i < numObjInstances; ++i)
			{
				HEU_InstanceInputObjectCache objCache = new HEU_InstanceInputObjectCache();

				objCache._inputName = objInstanceInfos[i]._partTarget.PartName + "_" + i;
				objCache._objInstanceSerialized = new SerializedObject(objInstanceInfos[i]);
				objCache._instancedInputsProperty = HEU_EditorUtility.GetSerializedProperty(objCache._objInstanceSerialized, "_instancedInputs");

				_instanceObjects.Add(objCache);
			}

			//Debug.Log("Created instance input cache!");
		}
Ejemplo n.º 12
0
		private void GenerateEditPointBoxNewMesh()
		{
			if (_selectedAttributesStore == null)
			{
				return;
			}

			Vector3[] positionArray = new Vector3[0];
			_selectedAttributesStore.GetPositionAttributeValues(out positionArray);

			int numPoints = positionArray.Length;
			if (numPoints != _previousEditMeshPointCount)
			{
				_editPointsSelectedIndices.Clear();
				_previousEditMeshPointCount = numPoints;
			}

			if (numPoints > 0)
			{
				float boxSize = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_editPointBoxSize").floatValue;
				Color unselectedColor = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_editPointBoxUnselectedColor").colorValue;
				Color selectedColor = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_editPointBoxSelectedColor").colorValue;

				if (_editPointBoxMaterial == null)
				{
					_editPointBoxMaterial = HEU_MaterialFactory.CreateNewHoudiniStandardMaterial("", "EditPointMaterial", false);
				}

				Color[] pointColors = new Color[numPoints];
				for (int i = 0; i < numPoints; ++i)
				{
					pointColors[i] = unselectedColor;
				}

				int numSelected = _editPointsSelectedIndices.Count;
				for (int i = 0; i < numSelected; ++i)
				{
					pointColors[_editPointsSelectedIndices[i]] = selectedColor;
				}

				_editPointBoxMesh = HEU_GeometryUtility.GenerateCubeMeshFromPoints(positionArray, pointColors, boxSize);

				_GUIChanged = true;
			}
		}
	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.º 14
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.º 15
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();
			}
		}
		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.º 17
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();
		}
Ejemplo n.º 18
0
	public bool DrawHandles(HEU_HoudiniAsset asset)
	{
	    List<HEU_Handle> handles = CacheHandles();

	    HEU_HandleManipMode manipMode = GetCurrentGlobalManipMode();

	    GUIStyle textStyle = new GUIStyle(EditorStyles.textField);
	    textStyle.contentOffset = new Vector2(1.4f, 1.4f);

	    HEU_Parameters assetParameters = asset.Parameters;
	    SerializedObject serializedParametersObject = new SerializedObject(assetParameters);
	    SerializedProperty parameterListProperty = HEU_EditorUtility.GetSerializedProperty(serializedParametersObject, "_parameterList");

	    bool bChanged = false;

	    Matrix4x4 defaultMatrix = Handles.matrix;

	    foreach (HEU_Handle handle in handles)
	    {
		if (handle.HandleType == HEU_Handle.HEU_HandleType.XFORM)
		{
		    Handles.matrix = asset.transform.localToWorldMatrix;

		    Vector3 handlePosition = handle.HandlePosition;
		    Quaternion handleRotation = handle.HandleRotation;
		    Vector3 handleScale = handle.HandleScale;

		    string handleName = handle.HandleName;

		    if (manipMode == HEU_HandleManipMode.MOVE)
		    {
			if (!handle.HasTranslateHandle())
			{
			    continue;
			}

			bool bDisabled = handle.IsTranslateHandleDisabled();
			if (bDisabled)
			{
			    handleName += " (disabled)";
			}

			GUIContent labelContent = new GUIContent(handleName);
			labelContent.tooltip = handleName;

			Handles.Label(handlePosition, labelContent, textStyle);

			if (bDisabled)
			{
			    bool bLighting = Handles.lighting;
			    Handles.lighting = false;
			    Handles.PositionHandle(handlePosition, handleRotation);
			    Handles.lighting = bLighting;
			    continue;
			}

			Vector3 updatedPosition = Handles.PositionHandle(handlePosition, handleRotation);
			if (updatedPosition != handlePosition)
			{
			    if (!handle.GetUpdatedPosition(asset, ref updatedPosition))
			    {
				continue;
			    }

			    HEU_HandleParamBinding translateBinding = handle.GetTranslateBinding();
			    if (translateBinding != null)
			    {
				HEU_ParameterData paramData = assetParameters.GetParameterWithParmID(translateBinding._parmID);
				if (paramData != null && paramData._unityIndex < parameterListProperty.arraySize)
				{
				    SerializedProperty paramDataProperty = parameterListProperty.GetArrayElementAtIndex(paramData._unityIndex);
				    float[] posFloats = new float[3];
				    posFloats[0] = updatedPosition[0];
				    posFloats[1] = updatedPosition[1];
				    posFloats[2] = updatedPosition[2];
				    bChanged |= UpdateFloatArrayProperty(paramDataProperty, posFloats, translateBinding);
				}
			    }
			}
		    }
		    else if (manipMode == HEU_HandleManipMode.ROTATE)
		    {
			if (!handle.HasRotateHandle())
			{
			    continue;
			}

			bool bDisabled = handle.IsRotateHandleDisabled();
			if (bDisabled)
			{
			    handleName += " (disabled)";
			}

			GUIContent labelContent = new GUIContent(handleName);
			labelContent.tooltip = handleName;

			Handles.Label(handlePosition, labelContent, textStyle);

			if (bDisabled)
			{
			    bool bLighting = Handles.lighting;
			    Handles.lighting = false;
			    Handles.RotationHandle(handleRotation, handlePosition);
			    Handles.lighting = bLighting;
			    continue;
			}

			Quaternion updatedRotation = Handles.RotationHandle(handleRotation, handlePosition);
			if (updatedRotation != handleRotation)
			{
			    if (!handle.GetUpdatedRotation(asset, ref updatedRotation))
			    {
				continue;
			    }

			    HEU_HandleParamBinding rotateBinding = handle.GetRotateBinding();
			    if (rotateBinding != null)
			    {
				HEU_ParameterData paramData = assetParameters.GetParameterWithParmID(rotateBinding._parmID);
				if (paramData != null && paramData._unityIndex < parameterListProperty.arraySize)
				{
				    SerializedProperty paramDataProperty = parameterListProperty.GetArrayElementAtIndex(paramData._unityIndex);
				    float[] rotFloats = new float[3];
				    rotFloats[0] = updatedRotation[0];
				    rotFloats[1] = updatedRotation[1];
				    rotFloats[2] = updatedRotation[2];
				    bChanged |= UpdateFloatArrayProperty(paramDataProperty, rotFloats, rotateBinding);
				}
			    }
			}
		    }
		    else if (manipMode == HEU_HandleManipMode.SCALE)
		    {
			if (!handle.HasScaleHandle())
			{
			    continue;
			}

			bool bDisabled = handle.IsScaleHandleDisabled();
			if (bDisabled)
			{
			    handleName += " (disabled)";
			}

			GUIContent labelContent = new GUIContent(handleName);
			labelContent.tooltip = handleName;

			Handles.Label(handlePosition, labelContent, textStyle);

			if (bDisabled)
			{
			    bool bLighting = Handles.lighting;
			    Handles.lighting = false;
			    Handles.ScaleHandle(handleScale, handlePosition, handleRotation, 1f);
			    Handles.lighting = bLighting;
			    continue;
			}

			Vector3 updatedScale = Handles.ScaleHandle(handleScale, handlePosition, handleRotation, 1f);
			if (updatedScale != handleScale)
			{
			    HEU_HandleParamBinding scaleBinding = handle.GetScaleBinding();
			    if (scaleBinding != null)
			    {
				HEU_ParameterData paramData = assetParameters.GetParameterWithParmID(scaleBinding._parmID);
				if (paramData != null && paramData._unityIndex < parameterListProperty.arraySize)
				{
				    SerializedProperty paramDataProperty = parameterListProperty.GetArrayElementAtIndex(paramData._unityIndex);
				    float[] scaleFloats = new float[3];
				    scaleFloats[0] = updatedScale[0];
				    scaleFloats[1] = updatedScale[1];
				    scaleFloats[2] = updatedScale[2];
				    bChanged |= UpdateFloatArrayProperty(paramDataProperty, scaleFloats, scaleBinding);
				}
			    }
			}
		    }
		}
	    }

	    if (bChanged)
	    {
		serializedParametersObject.ApplyModifiedProperties();
	    }

	    Handles.matrix = defaultMatrix;

	    return bChanged;
	}
Ejemplo n.º 19
0
	/// <summary>
	/// Main function to display linked asset's info, and functions.
	/// </summary>
	private void DrawAssetLink()
	{
	    HEU_PDGAssetLink.LinkState validState = _assetLink.AssetLinkState;

	    using (new EditorGUILayout.VerticalScope(_backgroundStyle))
	    {
		EditorGUILayout.Space();

		// Linked asset
		SerializedProperty assetGOProp = HEU_EditorUtility.GetSerializedProperty(serializedObject, "_assetGO");
		if (assetGOProp != null)
		{
		    EditorGUILayout.PropertyField(assetGOProp, _assetGOLabel, false);
		}

		EditorGUILayout.Space();

		using (new EditorGUILayout.HorizontalScope())
		{
		    // Refresh button re-poplates the UI data from linked asset
		    if (GUILayout.Button(_refreshContent, GUILayout.MaxHeight(_largButtonHeight)))
		    {
			_assetLink.Refresh();
		    }

		    // Reset button resets and recreates the HEU_PDGAssetLink
		    if (GUILayout.Button(_resetContent, GUILayout.MaxHeight(_largButtonHeight)))
		    {
			_assetLink.Reset();
		    }
		}

		// Autocook allows to automatically cook the TOP network when input assets are cooked
		_assetLink._autoCook = EditorGUILayout.Toggle(_autocookContent, _assetLink._autoCook);

		// Whether to use HEngine meta data to filter TOP networks and nodes
		_assetLink._useHEngineData = EditorGUILayout.Toggle(_useHEngineDataContent, _assetLink._useHEngineData);

		EditorGUILayout.Space();

		// Asset status
		using (new EditorGUILayout.VerticalScope(HEU_EditorUI.GetSectionStyle()))
		{
		    EditorGUILayout.LabelField("Asset is " + validState);

		    if (validState == HEU_PDGAssetLink.LinkState.ERROR_NOT_LINKED)
		    {
			EditorGUILayout.LabelField("Failed to link with HDA. Unable to proceed. Try rebuilding asset.");
		    }
		    else if (validState == HEU_PDGAssetLink.LinkState.LINKED)
		    {
			EditorGUILayout.Space();

			EditorGUILayout.LabelField(_assetStatusLabel);

			DrawWorkItemTally(_assetLink._workItemTally);

			EditorGUILayout.Space();
		    }
		}
	    }

	    if (validState == HEU_PDGAssetLink.LinkState.INACTIVE)
	    {
		_assetLink.Refresh();
	    }
	    else if (validState == HEU_PDGAssetLink.LinkState.LINKED)
	    {
		using (new EditorGUILayout.VerticalScope(_backgroundStyle))
		{
		    EditorGUILayout.Space();

		    DrawSelectedTOPNetwork();

		    EditorGUILayout.Space();

		    DrawSelectedTOPNode();
		}
	    }

	    // Display cook event messages
	    string eventMsgs = "<color=#c0c0c0ff>Cook event messages and errors will be displayed here...</color>";
	    HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
	    if (pdgSession != null)
	    {
		string actualMsgs = pdgSession.GetEventMessages();
		if (!string.IsNullOrEmpty(actualMsgs))
		{
		    eventMsgs = string.Format("{0}", actualMsgs);
		}
	    }

	    using (new EditorGUILayout.VerticalScope(_backgroundStyle))
	    {
		EditorGUILayout.Space();

		_eventMessageScrollPos = EditorGUILayout.BeginScrollView(_eventMessageScrollPos, false, false);
		Vector2 textSize = _eventMessageStyle.CalcSize(new GUIContent(eventMsgs));
		EditorGUILayout.PrefixLabel(_eventMessageContent);
		EditorGUILayout.SelectableLabel(eventMsgs, _eventMessageStyle, GUILayout.ExpandHeight(true),
			GUILayout.ExpandWidth(true), GUILayout.MinWidth(textSize.x), GUILayout.MinHeight(textSize.y));
		EditorGUILayout.EndScrollView();
	    }
	}
        /// <summary>
        /// Draw the UI for the given input node
        /// </summary>
        /// <param name="inputNode"></param>
        public static void EditorDrawInputNode(HEU_InputNode inputNode)
        {
            int plusButtonWidth = 20;

            //GUIStyle boldLabelStyle = new GUIStyle(EditorStyles.boldLabel);
            //boldLabelStyle.alignment = TextAnchor.UpperLeft;

            GUIContent inputTypeLabel = new GUIContent("Input Type");

            GUIContent translateLabel = new GUIContent("    Translate");
            GUIContent rotateLabel    = new GUIContent("    Rotate");
            GUIContent scaleLabel     = new GUIContent("    Scale");

            PopulateCache(inputNode);

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            string labelName = inputNode.LabelName;

            if (!string.IsNullOrEmpty(labelName))
            {
                EditorGUILayout.LabelField(labelName);
            }

            EditorGUI.indentLevel++;

            HEU_InputNode.InputObjectType inputObjectType             = (HEU_InputNode.InputObjectType)inputNode._uiCache._inputObjectTypeProperty.intValue;
            HEU_InputNode.InputObjectType userSelectedInputObjectType = (HEU_InputNode.InputObjectType)EditorGUILayout.EnumPopup(inputTypeLabel, inputObjectType);
            if (userSelectedInputObjectType != inputObjectType)
            {
                SerializedProperty pendingInputObjectTypeProperty = HEU_EditorUtility.GetSerializedProperty(inputNode._uiCache._inputNodeSerializedObject, "_pendingInputObjectType");
                if (pendingInputObjectTypeProperty != null)
                {
                    pendingInputObjectTypeProperty.intValue = (int)userSelectedInputObjectType;
                }
            }
            else
            {
                EditorGUILayout.PropertyField(inputNode._uiCache._keepWorldTransformProperty);
                EditorGUILayout.PropertyField(inputNode._uiCache._packBeforeMergeProperty);

                if (inputObjectType == HEU_InputNode.InputObjectType.HDA)
                {
                    SerializedProperty inputAssetsProperty = inputNode._uiCache._inputAssetsProperty;
                    if (inputAssetsProperty != null)
                    {
                        int  inputCount    = inputAssetsProperty.arraySize;
                        bool bSkipElements = false;

                        HEU_EditorUI.DrawSeparator();

                        EditorGUILayout.LabelField(string.Format("{0} input objects", inputCount));

                        using (var hs1 = new EditorGUILayout.HorizontalScope())
                        {
                            if (GUILayout.Button("Add Slot"))
                            {
                                inputAssetsProperty.InsertArrayElementAtIndex(inputCount);

                                bSkipElements = true;
                            }

                            if (GUILayout.Button("Add Selection"))
                            {
                                HEU_SelectionWindow.ShowWindow(inputNode.HandleSelectedObjectsForInputHDAs, typeof(HEU_HoudiniAssetRoot));
                            }

                            if (GUILayout.Button("Clear"))
                            {
                                inputAssetsProperty.ClearArray();
                                bSkipElements = true;
                            }
                        }

                        if (!bSkipElements)
                        {
                            using (var vs1 = new EditorGUILayout.VerticalScope())
                            {
                                for (int i = 0; i < inputCount; ++i)
                                {
                                    using (var hs2 = new EditorGUILayout.HorizontalScope())
                                    {
                                        EditorGUILayout.LabelField("Input " + (i + 1));

                                        if (GUILayout.Button("+", GUILayout.Width(plusButtonWidth)))
                                        {
                                            inputAssetsProperty.InsertArrayElementAtIndex(i);
                                            break;
                                        }

                                        if (GUILayout.Button("-", GUILayout.Width(plusButtonWidth)))
                                        {
                                            inputAssetsProperty.DeleteArrayElementAtIndex(i);
                                            break;
                                        }
                                    }

                                    EditorGUI.indentLevel++;
                                    using (var vs4 = new EditorGUILayout.VerticalScope())
                                    {
                                        HEU_InputNodeUICache.HEU_InputAssetUICache assetCache = inputNode._uiCache._inputAssetCache[i];

                                        UnityEngine.Object setObject = EditorGUILayout.ObjectField(assetCache._gameObjectProperty.objectReferenceValue, typeof(HEU_HoudiniAssetRoot), true);
                                        if (setObject != assetCache._gameObjectProperty.objectReferenceValue)
                                        {
                                            GameObject inputGO = setObject != null ? (setObject as HEU_HoudiniAssetRoot).gameObject : null;
                                            // Check not setting same asset as self
                                            if (inputGO == null || inputGO != inputNode.ParentAsset.RootGameObject)
                                            {
                                                assetCache._gameObjectProperty.objectReferenceValue = inputGO;
                                            }
                                        }
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }
                        }
                    }
                }
                //else if (inputObjectType == HEU_InputNode.InputObjectType.CURVE)
                //{
                //	TODO INPUT CURVE
                //}
                else if (inputObjectType == HEU_InputNode.InputObjectType.UNITY_MESH)
                {
                    SerializedProperty inputObjectsProperty = inputNode._uiCache._inputObjectsProperty;
                    if (inputObjectsProperty != null)
                    {
                        bool bSkipElements = false;

                        HEU_EditorUI.DrawSeparator();

                        EditorGUILayout.LabelField(string.Format("{0} input objects", inputObjectsProperty.arraySize));

                        using (var hs1 = new EditorGUILayout.HorizontalScope())
                        {
                            if (GUILayout.Button("Add Slot"))
                            {
                                inputObjectsProperty.arraySize++;
                                FixUpScaleProperty(inputObjectsProperty, inputObjectsProperty.arraySize - 1);

                                bSkipElements = true;
                            }

                            if (GUILayout.Button("Add Selection"))
                            {
                                HEU_SelectionWindow.ShowWindow(inputNode.HandleSelectedObjectsForInputObjects, typeof(GameObject));
                            }

                            if (GUILayout.Button("Clear"))
                            {
                                inputObjectsProperty.ClearArray();
                                bSkipElements = true;
                            }
                        }

                        if (!bSkipElements)
                        {
                            using (var vs1 = new EditorGUILayout.VerticalScope())
                            {
                                int inputCount = inputObjectsProperty.arraySize;
                                for (int i = 0; i < inputCount; ++i)
                                {
                                    using (var hs2 = new EditorGUILayout.HorizontalScope())
                                    {
                                        EditorGUILayout.LabelField("Input " + (i + 1));

                                        //using (var vs3 = new EditorGUILayout.VerticalScope())
                                        {
                                            if (GUILayout.Button("+", GUILayout.Width(plusButtonWidth)))
                                            {
                                                inputObjectsProperty.InsertArrayElementAtIndex(i);
                                                FixUpScaleProperty(inputObjectsProperty, i);
                                                break;
                                            }

                                            if (GUILayout.Button("-", GUILayout.Width(plusButtonWidth)))
                                            {
                                                inputObjectsProperty.DeleteArrayElementAtIndex(i);
                                                break;
                                            }
                                        }
                                    }

                                    EditorGUI.indentLevel++;
                                    using (var vs4 = new EditorGUILayout.VerticalScope())
                                    {
                                        HEU_InputNodeUICache.HEU_InputObjectUICache objectCache = inputNode._uiCache._inputObjectCache[i];

                                        EditorGUILayout.PropertyField(objectCache._gameObjectProperty, GUIContent.none);

                                        using (new EditorGUI.DisabledScope(!inputNode._uiCache._keepWorldTransformProperty.boolValue))
                                        {
                                            objectCache._transformOffsetProperty.boolValue = HEU_EditorUI.DrawToggleLeft(objectCache._transformOffsetProperty.boolValue, "Transform Offset");
                                            if (objectCache._transformOffsetProperty.boolValue)
                                            {
                                                objectCache._translateProperty.vector3Value = EditorGUILayout.Vector3Field(translateLabel, objectCache._translateProperty.vector3Value);
                                                objectCache._rotateProperty.vector3Value    = EditorGUILayout.Vector3Field(rotateLabel, objectCache._rotateProperty.vector3Value);
                                                objectCache._scaleProperty.vector3Value     = EditorGUILayout.Vector3Field(scaleLabel, objectCache._scaleProperty.vector3Value);
                                            }
                                        }
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }
                        }
                    }
                }
            }

            EditorGUI.indentLevel--;

            EditorGUILayout.EndVertical();

            if (EditorGUI.EndChangeCheck())
            {
                inputNode._uiCache._inputNodeSerializedObject.ApplyModifiedProperties();

                // When cooking, this will force input data to be uploaded
                inputNode.RequiresUpload = true;
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Draw the UI for the given input node
        /// </summary>
        /// <param name="inputNode"></param>
        public static void EditorDrawInputNode(HEU_InputNode inputNode)
        {
            int plusButtonWidth = 20;

            const string inputTypeTooltip = @"Input type of the object. 

The HDA type can accept any object with a HEU_HoudiniAssetRoot component. (Including curves)

The UNITY_MESH type can accept any GameObject (Including Terrain, HEU_BoundingVolumes).";
            GUIContent   inputTypeLabel   = new GUIContent("Input Type", inputTypeTooltip);

            GUIContent translateLabel = new GUIContent("    Translate");
            GUIContent rotateLabel    = new GUIContent("    Rotate");
            GUIContent scaleLabel     = new GUIContent("    Scale");

            PopulateCache(inputNode);

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            string labelName = inputNode.LabelName;

            if (!string.IsNullOrEmpty(labelName))
            {
                EditorGUILayout.LabelField(labelName);
            }

            EditorGUI.indentLevel++;

            HEU_InputNode.InputObjectType inputObjectType             = (HEU_InputNode.InputObjectType)inputNode._uiCache._inputObjectTypeProperty.intValue;
            HEU_InputNode.InputObjectType userSelectedInputObjectType = (HEU_InputNode.InputObjectType)EditorGUILayout.EnumPopup(inputTypeLabel, inputObjectType);
            if (userSelectedInputObjectType != inputObjectType)
            {
                SerializedProperty pendingInputObjectTypeProperty = HEU_EditorUtility.GetSerializedProperty(inputNode._uiCache._inputNodeSerializedObject, "_pendingInputObjectType");
                if (pendingInputObjectTypeProperty != null)
                {
                    pendingInputObjectTypeProperty.intValue = (int)userSelectedInputObjectType;
                }
            }
            else
            {
                EditorGUILayout.PropertyField(inputNode._uiCache._keepWorldTransformProperty);
                EditorGUILayout.PropertyField(inputNode._uiCache._packBeforeMergeProperty);

                if (HEU_InputNode.GetInternalObjectType(inputObjectType) == HEU_InputNode.InternalObjectType.HDA)
                {
                    SerializedProperty inputAssetsProperty = inputNode._uiCache._inputAssetsProperty;
                    if (inputAssetsProperty != null)
                    {
                        int  inputCount    = inputAssetsProperty.arraySize;
                        bool bSkipElements = false;

                        HEU_EditorUI.DrawSeparator();

                        EditorGUILayout.LabelField(string.Format("{0} input objects", inputCount));

                        using (var hs1 = new EditorGUILayout.HorizontalScope())
                        {
                            if (GUILayout.Button("Add Slot"))
                            {
                                inputAssetsProperty.InsertArrayElementAtIndex(inputCount);
                                bSkipElements = true;
                            }

                            if (GUILayout.Button("Clear"))
                            {
                                inputAssetsProperty.ClearArray();
                                bSkipElements = true;
                            }
                        }

                        DrawSelectionWindow(HEU_InputNode.InputObjectType.HDA, inputNode);

                        if (!bSkipElements)
                        {
                            using (var vs1 = new EditorGUILayout.VerticalScope())
                            {
                                for (int i = 0; i < inputCount; ++i)
                                {
                                    using (var hs2 = new EditorGUILayout.HorizontalScope())
                                    {
                                        EditorGUILayout.LabelField("Input " + (i + 1));

                                        if (GUILayout.Button("+", GUILayout.Width(plusButtonWidth)))
                                        {
                                            inputAssetsProperty.InsertArrayElementAtIndex(i);
                                            break;
                                        }

                                        if (GUILayout.Button("-", GUILayout.Width(plusButtonWidth)))
                                        {
                                            inputAssetsProperty.DeleteArrayElementAtIndex(i);
                                            break;
                                        }
                                    }

                                    EditorGUI.indentLevel++;
                                    using (var vs4 = new EditorGUILayout.VerticalScope())
                                    {
                                        if (i < inputNode._uiCache._inputAssetCache.Count)
                                        {
                                            HEU_InputNodeUICache.HEU_InputAssetUICache assetCache = inputNode._uiCache._inputAssetCache[i];

                                            UnityEngine.Object setObject = EditorGUILayout.ObjectField(assetCache._gameObjectProperty.objectReferenceValue, typeof(HEU_HoudiniAssetRoot), true);
                                            if (setObject != assetCache._gameObjectProperty.objectReferenceValue)
                                            {
                                                GameObject inputGO = setObject != null ? (setObject as HEU_HoudiniAssetRoot).gameObject : null;
                                                // Check not setting same asset as self
                                                if (inputGO == null || inputGO != inputNode.ParentAsset.RootGameObject)
                                                {
                                                    assetCache._gameObjectProperty.objectReferenceValue = inputGO;
                                                }
                                            }
                                        }
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }
                        }
                    }
                }
                else if (HEU_InputNode.GetInternalObjectType(inputObjectType) == HEU_InputNode.InternalObjectType.UNITY_MESH)
                {
                    SerializedProperty inputObjectsProperty = inputNode._uiCache._inputObjectsProperty;
                    if (inputObjectsProperty != null)
                    {
                        bool bSkipElements = false;

                        HEU_EditorUI.DrawSeparator();

                        EditorGUILayout.LabelField(string.Format("{0} input objects", inputObjectsProperty.arraySize));

                        using (var hs1 = new EditorGUILayout.HorizontalScope())
                        {
                            if (GUILayout.Button("Add Slot"))
                            {
                                inputObjectsProperty.arraySize++;
                                FixUpScaleProperty(inputObjectsProperty, inputObjectsProperty.arraySize - 1);
                                bSkipElements = true;
                            }

                            if (GUILayout.Button("Clear"))
                            {
                                inputObjectsProperty.ClearArray();
                                bSkipElements = true;
                            }
                        }

                        DrawSelectionWindow(inputObjectType, inputNode);

                        if (inputObjectType == HEU_InputNode.InputObjectType.UNITY_MESH && inputNode.MeshSettings != null)
                        {
                            HEU_EditorUI.DrawHeadingLabel("Mesh settings");
                            EditorGUI.indentLevel++;
                            {
                                UnityEditor.SerializedProperty exportCollidersProperty = inputNode._uiCache._meshSettingsProperty.FindPropertyRelative("_exportColliders");

                                exportCollidersProperty.boolValue = HEU_EditorUI.DrawToggleLeft(exportCollidersProperty.boolValue, _meshExportCollidersContent.text, _meshExportCollidersContent.tooltip);
                            }
                            EditorGUI.indentLevel--;
                        }
                        else if (inputObjectType == HEU_InputNode.InputObjectType.TILEMAP && inputNode.TilemapSettings != null)
                        {
                            HEU_EditorUI.DrawHeadingLabel("Tilemap settings");
                            EditorGUI.indentLevel++;
                            {
                                UnityEditor.SerializedProperty createGroupsForTilesProperty    = inputNode._uiCache._tilemapSettingsProperty.FindPropertyRelative("_createGroupsForTiles");
                                UnityEditor.SerializedProperty exportUnusedTilesProperty       = inputNode._uiCache._tilemapSettingsProperty.FindPropertyRelative("_exportUnusedTiles");
                                UnityEditor.SerializedProperty applyTileColorProperty          = inputNode._uiCache._tilemapSettingsProperty.FindPropertyRelative("_applyTileColor");
                                UnityEditor.SerializedProperty applyTilemapOrientationProperty = inputNode._uiCache._tilemapSettingsProperty.FindPropertyRelative("_applyTilemapOrientation");

                                createGroupsForTilesProperty.boolValue    = HEU_EditorUI.DrawToggleLeft(createGroupsForTilesProperty.boolValue, _tilemapCreateGroupsContent.text, _tilemapCreateGroupsContent.tooltip);
                                exportUnusedTilesProperty.boolValue       = HEU_EditorUI.DrawToggleLeft(exportUnusedTilesProperty.boolValue, _tilemapExportUnusedTilesContent.text, _tilemapExportUnusedTilesContent.tooltip);
                                applyTileColorProperty.boolValue          = HEU_EditorUI.DrawToggleLeft(applyTileColorProperty.boolValue, _tilemapColorContent.text, _tilemapColorContent.tooltip);
                                applyTilemapOrientationProperty.boolValue = HEU_EditorUI.DrawToggleLeft(applyTilemapOrientationProperty.boolValue, _tilemapOrientationContent.text, _tilemapOrientationContent.tooltip);
                            }
                            EditorGUI.indentLevel--;
                        }

                        if (!bSkipElements)
                        {
                            using (var vs1 = new EditorGUILayout.VerticalScope())
                            {
                                int inputCount = inputObjectsProperty.arraySize;
                                for (int i = 0; i < inputCount; ++i)
                                {
                                    using (var hs2 = new EditorGUILayout.HorizontalScope())
                                    {
                                        EditorGUILayout.LabelField("Input " + (i + 1));

                                        {
                                            if (GUILayout.Button("+", GUILayout.Width(plusButtonWidth)))
                                            {
                                                inputObjectsProperty.InsertArrayElementAtIndex(i);
                                                FixUpScaleProperty(inputObjectsProperty, i);
                                                break;
                                            }

                                            if (GUILayout.Button("-", GUILayout.Width(plusButtonWidth)))
                                            {
                                                inputObjectsProperty.DeleteArrayElementAtIndex(i);
                                                break;
                                            }
                                        }
                                    }

                                    EditorGUI.indentLevel++;
                                    using (var vs4 = new EditorGUILayout.VerticalScope())
                                    {
                                        if (i < inputNode._uiCache._inputObjectCache.Count && i < inputNode.InputObjects.Count)
                                        {
                                            HEU_InputNodeUICache.HEU_InputObjectUICache objectCache = inputNode._uiCache._inputObjectCache[i];
                                            GameObject oldObject = inputNode.InputObjects[i]._gameObject;

                                            GameObject newObject = null;


                                            switch (inputObjectType)
                                            {
                                            case HEU_InputNode.InputObjectType.TERRAIN:
                                                inputNode.InputObjects[i]._terrainReference = EditorGUILayout.ObjectField(inputNode.InputObjects[i]._terrainReference, typeof(Terrain), true) as Terrain;

                                                if (inputNode.InputObjects[i]._terrainReference != null)
                                                {
                                                    newObject = inputNode.InputObjects[i]._terrainReference.gameObject;
                                                }

                                                break;

                                            case HEU_InputNode.InputObjectType.BOUNDING_BOX:
                                                inputNode.InputObjects[i]._boundingVolumeReference = EditorGUILayout.ObjectField(inputNode.InputObjects[i]._boundingVolumeReference, typeof(HEU_BoundingVolume), true) as HEU_BoundingVolume;

                                                if (inputNode.InputObjects[i]._boundingVolumeReference != null)
                                                {
                                                    newObject = inputNode.InputObjects[i]._boundingVolumeReference.gameObject;
                                                }

                                                break;

                                            case HEU_InputNode.InputObjectType.TILEMAP:
                                                inputNode.InputObjects[i]._tilemapReference = EditorGUILayout.ObjectField(inputNode.InputObjects[i]._tilemapReference, typeof(Tilemap), true) as Tilemap;

                                                if (inputNode.InputObjects[i]._tilemapReference != null)
                                                {
                                                    newObject = inputNode.InputObjects[i]._tilemapReference.gameObject;
                                                }

                                                break;

                                            default:
                                                newObject = EditorGUILayout.ObjectField(inputNode.InputObjects[i]._gameObject, typeof(GameObject), true) as GameObject;
                                                break;
                                            }


                                            if (oldObject != newObject)
                                            {
                                                Undo.RecordObject(inputNode, "GameObject Assign");
                                                inputNode.InputObjects[i]._gameObject = newObject;
                                                // Set the reference to avoid strange bugs when switching input type modes
                                                inputNode.InputObjects[i].SetReferencesFromGameObject();
                                                EditorUtility.SetDirty(inputNode);
                                            }

                                            using (new EditorGUI.DisabledScope(!inputNode._uiCache._keepWorldTransformProperty.boolValue))
                                            {
                                                objectCache._transformOffsetProperty.boolValue = HEU_EditorUI.DrawToggleLeft(objectCache._transformOffsetProperty.boolValue, "Transform Offset");
                                                if (objectCache._transformOffsetProperty.boolValue)
                                                {
                                                    objectCache._translateProperty.vector3Value = EditorGUILayout.Vector3Field(translateLabel, objectCache._translateProperty.vector3Value);
                                                    objectCache._rotateProperty.vector3Value    = EditorGUILayout.Vector3Field(rotateLabel, objectCache._rotateProperty.vector3Value);
                                                    objectCache._scaleProperty.vector3Value     = EditorGUILayout.Vector3Field(scaleLabel, objectCache._scaleProperty.vector3Value);
                                                }
                                            }
                                        }
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }
                        }
                    }
                }
            }

            EditorGUI.indentLevel--;

            EditorGUILayout.EndVertical();

            if (EditorGUI.EndChangeCheck())
            {
                inputNode._uiCache._inputNodeSerializedObject.ApplyModifiedProperties();

                // When cooking, this will force input data to be uploaded
                inputNode.RequiresUpload = true;
                inputNode.ClearUICache();
            }
        }
Ejemplo n.º 22
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.º 23
0
		private float GetBrushRadius()
		{
			SerializedProperty property = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintBrushSize");
			return (property != null) ? property.floatValue : 1f;
		}
Ejemplo n.º 24
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;
	}
Ejemplo n.º 25
0
		private void DrawAttributeSelection()
		{
			// Try to re-use the last selected node
			string lastSelectedNodeName = null;
			SerializedProperty lastSelectedNodeNameProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_lastAttributeNodeName");
			if (lastSelectedNodeNameProperty != null)
			{
				lastSelectedNodeName = lastSelectedNodeNameProperty.stringValue;
			}

			HEU_AttributesStore foundAttributeStore = null;

			// Get the names of the all editable nodes having an attribute store for this asset
			// While doing that, we'll find the last selected attribute store
			int lastSelectedIndex = 0;
			List<string> nodeNames = new List<string>();
			foreach (HEU_AttributesStore attributeStore in _attributesStores)
			{
				string geoName = attributeStore.GeoName;
				if (!nodeNames.Contains(geoName))
				{
					nodeNames.Add(geoName);

					// Either re-select last selected node, or select the first one found
					if (string.IsNullOrEmpty(lastSelectedNodeName) || lastSelectedNodeName.Equals(geoName))
					{
						lastSelectedNodeName = geoName;
						lastSelectedIndex = nodeNames.Count - 1;
						foundAttributeStore = attributeStore;
					}
				}
			}

			// Try to re-use the last selected attribute
			string lastSelectedAttributeName = null;
			SerializedProperty lastSelectedAttributeProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_lastAttributeName");
			if (lastSelectedAttributeProperty != null)
			{
				lastSelectedAttributeName = lastSelectedAttributeProperty.stringValue;
			}

			// Display a dropdown list of editable nodes with attribute stores
			int currentSelectedIndex = EditorGUILayout.Popup(_editableNodeLabel, lastSelectedIndex, nodeNames.ToArray());
			if (currentSelectedIndex != lastSelectedIndex)
			{
				// User changed node selection, so update it
				lastSelectedNodeName = nodeNames[currentSelectedIndex];

				foundAttributeStore = null;

				foreach (HEU_AttributesStore attributeStore in _attributesStores)
				{
					string geoName = attributeStore.GeoName;
					if (geoName.Equals(lastSelectedNodeName))
					{
						foundAttributeStore = attributeStore;
						break;
					}
				}

				SetSelectedAttributeStore(foundAttributeStore);

				// Reset selected attribute to first attribute
				SetSelectedAttributeData(_selectedAttributesStore.GetAttributeData(0));
				lastSelectedAttributeName = _selectedAttributeData._name;
				lastSelectedAttributeProperty.stringValue = lastSelectedAttributeName;

				lastSelectedNodeNameProperty.stringValue = lastSelectedNodeName;

				_GUIChanged = true;
			}
			else
			{
				// Since selected node hasn't changed, re-use the last selected attribute

				SetSelectedAttributeStore(foundAttributeStore);

				SetSelectedAttributeData(_selectedAttributesStore.GetAttributeData(lastSelectedAttributeName));
			}

			// Get attribute names for selected node
			List<string> attributeNames = _selectedAttributesStore.GetAttributeNames();

			// Find the last selected attribute index
			int lastAttributeIndex = -1;
			if (!string.IsNullOrEmpty(lastSelectedAttributeName))
			{
				for(int i = 0; i < attributeNames.Count; ++i)
				{
					if (lastSelectedAttributeName.Equals(attributeNames[i]))
					{
						lastAttributeIndex = i;
						break;
					}
				}
			}

			// Use first attribute as default if none selected last time
			if(lastAttributeIndex == -1)
			{
				lastAttributeIndex = 0;
				HEU_AttributeData data = _selectedAttributesStore.GetAttributeData(0);
				if (data != null)
				{
					lastSelectedAttributeProperty.stringValue = data._name;
				}
			}

			// Display attributes as dropdown
			if (attributeNames.Count > 0)
			{
				int currentAttributeIndex = EditorGUILayout.Popup(_attributeLabel, lastAttributeIndex, attributeNames.ToArray());
				if (currentAttributeIndex != lastAttributeIndex)
				{
					// User changed attribute selection, so update it
					SetSelectedAttributeData(_selectedAttributesStore.GetAttributeData(attributeNames[currentAttributeIndex]));
					lastSelectedAttributeProperty.stringValue = _selectedAttributeData._name;
				}
			}
		}
Ejemplo n.º 26
0
		private void DrawViewModeInfo()
		{
			float uiWidth = _editorUIRect.width * _infoPanelSettingsWidth;

			char upArrow = '\u25B2';
			char downArrow = '\u25BC';
			float arrayWidth = 25;

			GUIStyle editNodesBoxStyle = new GUIStyle(GUI.skin.textArea);
			GUIStyle entryStyle = new GUIStyle(GUI.skin.box);

			using (var hs = new EditorGUILayout.HorizontalScope())
			{
				using (var vs = new EditorGUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.MaxWidth(uiWidth)))
				{
					EditorGUILayout.LabelField("This tool allows to Paint & Edit POINT attributes of Editable nodes.");
					EditorGUILayout.LabelField("Painting vertex colors is directly supported if a Paint SOP is made editable.");
					EditorGUILayout.LabelField("Use node list on the right to re-order editable nodes by order of edit operations.");
					EditorGUILayout.LabelField("Nodes that take inputs from other editable nodes should come after them in the list.");
				}

				using (var vs = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
				{
					// Draw each editable node (attribute store), along with buttons to re-order the node.

					using (var hs2 = new EditorGUILayout.HorizontalScope())
					{
						HEU_EditorUI.DrawHeadingLabel("EDIT ORDER");

						SerializedProperty cookUpstreamSerializedProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_alwaysCookUpstream");
						if (cookUpstreamSerializedProperty != null)
						{
							EditorGUILayout.PropertyField(cookUpstreamSerializedProperty,
								new GUIContent("Always Cook Inputs", "For multiple editable nodes, this forces each one to always cook upstream inputs first before applying edits."),
								GUILayout.Width(168));
						}
					}

					using (var vs2 = new EditorGUILayout.VerticalScope(editNodesBoxStyle))
					{
						using (var scrollScope = new EditorGUILayout.ScrollViewScope(_editNodeScrollPos))
						{
							_editNodeScrollPos = scrollScope.scrollPosition;

							int numStores = _attributesStores.Count;
							for (int i = 0; i < numStores; ++i)
							{
								using (var hsi = new EditorGUILayout.HorizontalScope(entryStyle))
								{
									if (GUILayout.Button(upArrow.ToString(), GUILayout.MaxWidth(arrayWidth)))
									{
										if (i > 0)
										{
											_asset.ReorderAttributeStore(i, i - 1);
										}
									}

									if (GUILayout.Button(downArrow.ToString(), GUILayout.MaxWidth(arrayWidth)))
									{
										if (i < numStores - 1)
										{
											_asset.ReorderAttributeStore(i, i + 1);
										}
									}

									EditorGUILayout.LabelField(_attributesStores[i].GeoName);
								}
							}

						}
					}
				}
			}
		}
Ejemplo n.º 27
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.º 28
0
		private void DrawPaintModeScene()
		{
			if(_selectedAttributesStore == null || _selectedAttributeData == null)
			{
				// Nothing to do if no attribute selected
				return;
			}

			if(!_selectedAttributesStore.HasMeshForPainting())
			{
				// Painting requires a mesh so nothing to do
				return;
			}

			if (!_mouseWithinSceneView)
			{
				return;
			}

			float brushRadius = GetBrushRadius();

			// TODO: use Handles.DrawingScope
			Color originalHandleColor = Handles.color;
			Color newHandleColor = originalHandleColor;
			
			SerializedProperty handleColorProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_brushHandleColor");
			if(handleColorProperty != null)
			{
				newHandleColor = handleColorProperty.colorValue;
			}

			HEU_ToolsInfo.PaintMergeMode paintMergeMode = HEU_ToolsInfo.PaintMergeMode.REPLACE;
			SerializedProperty paintMergeProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintMergeMode");
			if (paintMergeProperty != null)
			{
				paintMergeMode = (HEU_ToolsInfo.PaintMergeMode)paintMergeProperty.intValue;
			}

			SerializedProperty isPaintingProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_isPainting");

			// Enable the mesh collider so that we can raycast to paint using brush
			MeshCollider collider = _selectedAttributesStore.GetPaintMeshCollider();
			if (collider != null)
			{
				Ray ray = _currentCamera.ScreenPointToRay(_mousePosition);
				ray.origin = _currentCamera.transform.position;

				RaycastHit hit;
				if (collider.Raycast(ray, out hit, _intersectionRayLength))
				{
					if (_currentEvent.type == EventType.ScrollWheel && _currentEvent.shift)
					{
						// Brush resize
						brushRadius -= _currentEvent.delta.y * _mouseWheelBrushSizeMultiplier;
						brushRadius = UpdateBrushSize(brushRadius);

						_GUIChanged = true;
						_currentEvent.Use();
					}
					else if (_currentEvent.type == EventType.MouseDrag && _currentEvent.shift)
					{
						// Brush resize
						brushRadius += _currentEvent.delta.x * _mouseWheelBrushSizeMultiplier;
						brushRadius = UpdateBrushSize(brushRadius);

						_GUIChanged = true;
						_currentEvent.Use();
					}
					else if (_currentEvent.button == 0 && !_currentEvent.shift && !_currentEvent.alt && !_currentEvent.control && !_mouseOverInfoPanel)
					{
						// Painting

						if (_currentEvent.type == EventType.MouseDown && !isPaintingProperty.boolValue)
						{
							PaintingStarted(isPaintingProperty);
						}

						if (isPaintingProperty.boolValue)
						{
							if(_currentEvent.type == EventType.MouseDown || _currentEvent.type == EventType.MouseDrag)
							{
								HandlePaintEvent(hit, brushRadius, paintMergeMode);

								_currentEvent.Use();
							}
						}
					}

					if (!_mouseOverInfoPanel)
					{
						Handles.color = newHandleColor;
						Vector3 endPt = hit.point + (Vector3.Normalize(hit.normal) * brushRadius);
						Handles.DrawAAPolyLine(2f, new Vector3[] { hit.point, endPt });

						HEU_EditorUI.DrawCircleCap(_controlID, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal), brushRadius);
					}
				}
			}

			switch (_currentEvent.type)
			{
				case EventType.MouseDown:
				{
					// Don't use event here as it will ignore mouse camera controls
					break;
				}
				case EventType.MouseUp:
				{
					if (_currentEvent.button == 0)
					{
						if(!_currentEvent.shift && !_currentEvent.alt && !_currentEvent.control)
						{
							if (isPaintingProperty != null && isPaintingProperty.boolValue)
							{
								_currentEvent.Use();
							}

							PaintingFinished(isPaintingProperty);
						}
					}
					break;
				}
				case EventType.MouseMove:
				{
					// Use the mouse move event will force a repaint allowing for much more responsive UI
					_currentEvent.Use();
					break;
				}
				case EventType.Layout:
				{
					// This disables deselection on asset while in Edit mode
					HandleUtility.AddDefaultControl(_controlID);

					break;
				}
				case EventType.Repaint:
				{
					
					break;
				}
			}

			Handles.color = originalHandleColor;
		}
Ejemplo n.º 29
0
		private void DrawPaintAttributeValues()
		{
			// Display the values as editable fields

			if (_selectedAttributeData == null)
			{
				return;
			}

			if(!_selectedAttributesStore.HasMeshForPainting())
			{
				HEU_EditorUI.DrawWarningLabel(_noMeshForPainting);
				return;
			}

			SerializedProperty selectedToolsValuesProperty = null;

			if (_selectedAttributeData._attributeType == HEU_AttributeData.AttributeType.INT)
			{
				selectedToolsValuesProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintIntValue");
				if (selectedToolsValuesProperty != null)
				{
					ResizeSerializedPropertyArray(selectedToolsValuesProperty, _selectedAttributeData._attributeInfo.tupleSize);
					HEU_EditorUtility.EditorDrawArrayProperty(selectedToolsValuesProperty, HEU_EditorUtility.EditorDrawIntProperty, _paintValuesLabel);
				}
			}
			else if (_selectedAttributeData._attributeType == HEU_AttributeData.AttributeType.FLOAT)
			{
				selectedToolsValuesProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintFloatValue");
				if (selectedToolsValuesProperty != null)
				{
					ResizeSerializedPropertyArray(selectedToolsValuesProperty, _selectedAttributeData._attributeInfo.tupleSize);
					HEU_EditorUtility.EditorDrawArrayProperty(selectedToolsValuesProperty, HEU_EditorUtility.EditorDrawFloatProperty, _paintValuesLabel);
				}

				// Display paint color selector if this is a color attribute
				if (_selectedAttributeData.IsColorAttribute())
				{
					Color color = Color.white;

					if (selectedToolsValuesProperty.arraySize >= 3)
					{
						color.r = selectedToolsValuesProperty.GetArrayElementAtIndex(0).floatValue;
						color.g = selectedToolsValuesProperty.GetArrayElementAtIndex(1).floatValue;
						color.b = selectedToolsValuesProperty.GetArrayElementAtIndex(2).floatValue;

						if (selectedToolsValuesProperty.arraySize >= 4)
						{
							color.a = selectedToolsValuesProperty.GetArrayElementAtIndex(3).floatValue;
						}
					}

					Color newColor = EditorGUILayout.ColorField(_paintColorLabel, color);
					if (color != newColor)
					{
						if (selectedToolsValuesProperty.arraySize >= 3)
						{
							selectedToolsValuesProperty.GetArrayElementAtIndex(0).floatValue = newColor.r;
							selectedToolsValuesProperty.GetArrayElementAtIndex(1).floatValue = newColor.g;
							selectedToolsValuesProperty.GetArrayElementAtIndex(2).floatValue = newColor.b;

							if (selectedToolsValuesProperty.arraySize >= 4)
							{
								selectedToolsValuesProperty.GetArrayElementAtIndex(3).floatValue = newColor.a;
							}
						}
					}
				}

			}
			else if (_selectedAttributeData._attributeType == HEU_AttributeData.AttributeType.STRING)
			{
				selectedToolsValuesProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintStringValue");
				if (selectedToolsValuesProperty != null)
				{
					ResizeSerializedPropertyArray(selectedToolsValuesProperty, _selectedAttributeData._attributeInfo.tupleSize);
					HEU_EditorUtility.EditorDrawArrayProperty(selectedToolsValuesProperty, HEU_EditorUtility.EditorDrawTextProperty, _paintValuesLabel);
				}
			}

			if (!_selectedAttributeData.IsColorAttribute())
			{
				HEU_EditorUtility.EditorDrawSerializedProperty(_toolsInfoSerializedObject, "_affectedAreaPaintColor", _affectedAreaColorLabel, "Color to show painted area.");
			}
		}
Ejemplo n.º 30
0
	/// <summary>
	/// Draw the Generate section.
	/// </summary>
	private static bool DrawGenerateSection(HEU_HoudiniAssetRoot assetRoot, 
	    SerializedObject assetRootSerializedObject, 
	    HEU_HoudiniAsset asset, SerializedObject assetObject,
	    ref HEU_HoudiniAsset.AssetBuildAction pendingBuildAction)
	{
	    bool bSkipAutoCook = false;

	    CreateMainButtonStyle();

	    _recookhdaContent.text = "  Recook";

	    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], _mainPromptStyle))
		    {
			selectedIndex = i;
			break;
		    }

		    EditorGUILayout.Separator();
		}

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

		bSkipAutoCook = 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)
		    {
			HEU_EditorUI.DrawSeparator();

			using (var hs = new EditorGUILayout.HorizontalScope(_mainBoxStyle))
			{
			    if (GUILayout.Button(_reloadhdaContent, _mainButtonStyle))
			    {
				pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.RELOAD;
				bSkipAutoCook = true;
			    }

			    GUILayout.Space(_mainButtonSeparatorDistance);

			    if (!bSkipAutoCook && GUILayout.Button(_recookhdaContent, _mainButtonStyle))
			    {
				pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.COOK;
				bSkipAutoCook = true;
			    }
			}

			using (var hs = new EditorGUILayout.HorizontalScope(_mainBoxStyle))
			{
			    if (GUILayout.Button(_duplicateContent, _mainButtonStyle))
			    {
				pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.DUPLICATE;
				bSkipAutoCook = true;
			    }

			    GUILayout.Space(_mainButtonSeparatorDistance);

			    if (GUILayout.Button(_resetParamContent, _mainButtonStyle))
			    {
				pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.RESET_PARAMS;
				bSkipAutoCook = true;
			    }
			}
		    }
		}

		HEU_EditorUI.EndSection();
	    }

	    HEU_EditorUI.DrawSeparator();

	    return bSkipAutoCook;
	}