private void DrawEmitterProperties()
 {
     using (var category = new PKFxEditorCategory(m_PlayOnStart, "Emitter"))
     {
         if (category.IsExpanded())
         {
             EditorGUI.BeginChangeCheck();
             {
                 EditorGUILayout.PropertyField(m_PlayOnStart);
                 EditorGUILayout.PropertyField(m_TriggerAndForget);
             }
             if (EditorGUI.EndChangeCheck())
             {
                 m_RequiresApplyModifiedProperties = true;
             }
         }
     }
 }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        PKFxSettings settings = (PKFxSettings)target;

        PKFxSettings.SetInstance(settings);

        using (var category = new PKFxEditorCategory(() => EditorGUILayout.Foldout(PKFxSettings.GeneralCategory, "General")))
        {
            PKFxSettings.GeneralCategory = category.IsExpanded();
            if (category.IsExpanded())
            {
                DisplayGeneralCategory();
            }
        }
        using (var category = new PKFxEditorCategory(() => EditorGUILayout.Foldout(PKFxSettings.RenderingCategory, "Rendering")))
        {
            PKFxSettings.RenderingCategory = category.IsExpanded();
            if (category.IsExpanded())
            {
                DisplayRenderingCategory();
            }
        }
        using (var category = new PKFxEditorCategory(() => EditorGUILayout.Foldout(PKFxSettings.ThreadingCategory, "Multithreading")))
        {
            PKFxSettings.ThreadingCategory = category.IsExpanded();
            if (category.IsExpanded())
            {
                DisplayThreadingCategory();
            }
        }

        if (PKFxSettings.EnableFileLog != PKFxManagerImpl.FileLoggingEnabled())
        {
            EditorGUILayout.HelpBox("At least one of the changes requires a restart of Unity to be effective.", MessageType.Warning, true);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(settings);
        }
    }
    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;
            }
        }
    }