public PKFxEditorCategory(Func <bool> customHeaderDrawer) { RectArea = EditorGUILayout.BeginVertical(EditorStyles.helpBox); ++EditorGUI.indentLevel; SetPropertyExpanded(customHeaderDrawer.Invoke()); if (IsExpanded()) { --EditorGUI.indentLevel; PkFxEditorSplitter.Splitter(); } }
private void StartIndentation(string categoryName) { RectArea = EditorGUILayout.BeginVertical(EditorStyles.helpBox); ++EditorGUI.indentLevel; SetPropertyExpanded(EditorGUILayout.Foldout(IsExpanded(), categoryName, true)); if (IsExpanded()) { --EditorGUI.indentLevel; PkFxEditorSplitter.Splitter(); } }
private void DrawAttributes() { if (m_FxAttributesDesc.arraySize == 0 && m_FxSamplers.arraySize == 0) { return; } using (var category = new PKFxEditorCategory(DrawAttributesHeader)) { if (!category.IsExpanded()) { return; } EditorGUI.BeginChangeCheck(); { int numLine = 0; if (serializedObject.targetObjects.Length == 1) { PKFxFX fx = target as PKFxFX; bool attributesChanged = false; PKFxAttributesContainer attribContainer = fx.m_AttributesContainer; for (int i = 0; i < m_FxAttributesDesc.arraySize; i++) { SerializedProperty attrDesc = m_FxAttributesDesc.GetArrayElementAtIndex(i); SerializedProperty valueX = m_FxAttributesStartValues.GetArrayElementAtIndex(i * 4 + 0); SerializedProperty valueY = m_FxAttributesStartValues.GetArrayElementAtIndex(i * 4 + 1); SerializedProperty valueZ = m_FxAttributesStartValues.GetArrayElementAtIndex(i * 4 + 2); SerializedProperty valueW = m_FxAttributesStartValues.GetArrayElementAtIndex(i * 4 + 3); SetColorBackgroundByParity(numLine); if (PKFxAttributePropertyDrawer.DrawAttribute(attrDesc, valueX, valueY, valueZ, valueW)) { if (attribContainer != null) // The FX is not started { attributesChanged = true; attribContainer.SetAttributeUnsafe(i, valueX.floatValue, valueY.floatValue, valueZ.floatValue, valueW.floatValue); } } EditorGUILayout.EndVertical(); ++numLine; } if (attributesChanged) { attribContainer.UpdateAttributes(); } if (m_FxAttributesDesc.arraySize > 0 && m_FxSamplers.arraySize > 0) { PkFxEditorSplitter.Splitter(0); } for (int i = 0; i < m_FxSamplers.arraySize; i++) { SerializedProperty smp = m_FxSamplers.GetArrayElementAtIndex(i); SamplerField(smp); } } //Clear FxName, Attributes and Samplers if the asset is None if (m_FxAsset.objectReferenceInstanceIDValue == 0) { m_FxAttributesDesc.ClearArray(); m_FxAttributesStartValues.ClearArray(); m_FxSamplers.ClearArray(); m_FxName.stringValue = ""; } } if (EditorGUI.EndChangeCheck()) { m_RequiresApplyModifiedProperties = true; } } }