public override void OnInspectorGUI()
    {
        if (dataObject != null)
        {
            dataObject.Update();
        }

        if (srpSubOutputObject != null)
        {
            srpSubOutputObject.Update();
        }

        if (m_ContextController != null && m_ContextController.letter != '\0')
        {
            GUILayout.Label(m_ContextController.letter.ToString(), Styles.letter);
        }

        base.OnInspectorGUI();

        bool invalidateContext = (dataObject != null && dataObject.ApplyModifiedProperties()) || (srpSubOutputObject != null && srpSubOutputObject.ApplyModifiedProperties());

        if (invalidateContext)
        {
            foreach (VFXContext ctx in targets.OfType <VFXContext>())
            {
                // notify that something changed.
                ctx.GetData().Invalidate(VFXModel.InvalidationCause.kSettingChanged); // This will also invalidate contexts
            }
        }

        if (serializedObject.isEditingMultipleObjects)
        {
            return;                                            // Summary Only visible for single selection
        }
        // Context / SystemData
        if (dataObject == null)
        {
            return;
        }
        var context = (VFXContext)target;
        var data    = (VFXData)dataObject.targetObject;

        // Particle context data
        if (data.type == VFXDataType.Particle)
        {
            VFXDataParticle particleData = data as VFXDataParticle;
            EditorGUILayout.Space();
            {
                Styles.Row(Styles.header, "Name", "Value");
                Styles.Row(Styles.cell, "Capacity", particleData.GetSettingValue("capacity").ToString());

                EditorGUILayout.Space();

                var attributes = data.GetAttributes();

                if (attributes.Count() > 0)
                {
                    EditorGUILayout.LabelField("System Attribute Summary", Styles.header);

                    foreach (var attr in attributes)
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            GUILayout.Label(attr.attrib.name, Styles.cell);
                            Styles.DataTypeLabel(attr.attrib.type.ToString(), attr.attrib.type, Styles.cell, GUILayout.Width(64));
                            int size = VFXExpressionHelper.GetSizeOfType(attr.attrib.type) * 4;
                            GUILayout.Label(size + " byte" + (size > 1 ? "s" : ""), Styles.cell, GUILayout.Width(64));
                            var mode = attr.mode;
                            GUILayout.Label(mode.ToString(), Styles.cell, GUILayout.Width(64));
                        }
                    }
                }

                StructureOfArrayProvider.BucketInfo[] current = particleData.GetCurrentAttributeLayout();
                StructureOfArrayProvider.BucketInfo[] source  = particleData.GetSourceAttributeLayout();

                if (current.Length > 0)
                {
                    GUILayout.Space(24);
                    DoAttributeLayoutGUI("Current Attribute Layout", current);
                }

                if (source.Length > 0)
                {
                    GUILayout.Space(12);
                    DoAttributeLayoutGUI("Source Attribute Layout", source);
                }
            }
        }

        if (VFXViewPreference.displayExtraDebugInfo)
        {
            // Extra debug data
            EditorGUILayout.Space();
            {
                Styles.Row(Styles.header, "Name", "Value");
                Styles.Row(Styles.cell, "Context Type", context.contextType.ToString());
                Styles.Row(Styles.cell, "Task Type", context.taskType.ToString());
                Styles.Row(Styles.cell, "Input Data Type", context.inputType.ToString());
                Styles.Row(Styles.cell, "Context Data Type", data.type.ToString());
                Styles.Row(Styles.cell, "Can Be Compiled", context.CanBeCompiled().ToString());

                EditorGUILayout.Space();

                var attributeInfos = data.GetAttributesForContext(context);
                VFXAttributeInfo[] infos;

                // Early check for context consistency
                try
                {
                    infos = attributeInfos.ToArray();
                }
                catch
                {
                    return;
                }

                EditorGUILayout.LabelField("Attributes used by Context", Styles.header);

                foreach (var info in infos)
                {
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUILayout.Label(info.attrib.name, Styles.cell);
                        Styles.DataTypeLabel(info.attrib.type.ToString(), info.attrib.type, Styles.cell, GUILayout.Width(80));
                        Styles.AttributeModeLabel(info.mode.ToString(), info.mode, Styles.cell, GUILayout.Width(80));
                    }
                }

                EditorGUILayout.Space();

                Styles.Row(Styles.header, "Blocks");
                foreach (var block in context.activeChildrenWithImplicit)
                {
                    Styles.Row(Styles.cell, block.name, !context.children.Contains(block) ? "implicit" : "");
                }

                EditorGUILayout.Space();
            }
        }
    }
示例#2
0
    protected void DisplaySummary()
    {
        if (serializedObject.isEditingMultipleObjects)
        {
            return;                                            // Summary Only visible for single selection
        }
        // Context / SystemData
        if (dataObject == null)
        {
            return;
        }
        var context = (VFXContext)target;
        var data    = (VFXData)dataObject.targetObject;

        // Particle context data
        if (data.type == VFXDataType.Particle)
        {
            VFXDataParticle particleData = data as VFXDataParticle;
            EditorGUILayout.Space();
            {
                Styles.Row(Styles.header, "Name", "Value");
                Styles.Row(Styles.cell, "Capacity", particleData.GetSettingValue("capacity").ToString());

                EditorGUILayout.Space();

                var attributes = data.GetAttributes();

                if (attributes.Count() > 0)
                {
                    EditorGUILayout.LabelField("System Attribute Summary", Styles.header);

                    foreach (var attr in attributes)
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            GUILayout.Label(attr.attrib.name, Styles.cell);
                            Styles.DataTypeLabel(attr.attrib.type.ToString(), attr.attrib.type, Styles.cell, GUILayout.Width(64));
                            int size = VFXExpressionHelper.GetSizeOfType(attr.attrib.type) * 4;
                            GUILayout.Label(size + " byte" + (size > 1 ? "s" : ""), Styles.cell, GUILayout.Width(64));
                            var mode = attr.mode;
                            GUILayout.Label(mode.ToString(), Styles.cell, GUILayout.Width(72));
                        }
                    }
                }

                StructureOfArrayProvider.BucketInfo[] current = particleData.GetCurrentAttributeLayout();
                StructureOfArrayProvider.BucketInfo[] source  = particleData.GetSourceAttributeLayout();

                if (current.Length > 0)
                {
                    GUILayout.Space(24);
                    DoAttributeLayoutGUI("Current Attribute Layout", current);
                }

                if (source.Length > 0)
                {
                    GUILayout.Space(12);
                    DoAttributeLayoutGUI("Source Attribute Layout", source);
                }
            }
        }

        if (VFXViewPreference.displayExtraDebugInfo)
        {
            // Extra debug data
            EditorGUILayout.Space();
            {
                Styles.Row(Styles.header, "Name", "Value");
                Styles.Row(Styles.cell, "Context Type", context.contextType.ToString());
                Styles.Row(Styles.cell, "Task Type", context.taskType.ToString());
                Styles.Row(Styles.cell, "Input Data Type", context.inputType.ToString());
                Styles.Row(Styles.cell, "Context Data Type", data.type.ToString());
                Styles.Row(Styles.cell, "Can Be Compiled", context.CanBeCompiled().ToString());

                EditorGUILayout.Space();

                var attributeInfos = data.GetAttributesForContext(context);
                VFXAttributeInfo[] infos;

                // Early check for context consistency
                try
                {
                    infos = attributeInfos.ToArray();
                }
                catch
                {
                    return;
                }

                EditorGUILayout.LabelField("Attributes used by Context", Styles.header);

                foreach (var info in infos)
                {
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUILayout.Label(info.attrib.name, Styles.cell);
                        Styles.DataTypeLabel(info.attrib.type.ToString(), info.attrib.type, Styles.cell, GUILayout.Width(80));
                        Styles.AttributeModeLabel(info.mode.ToString(), info.mode, Styles.cell, GUILayout.Width(80));
                    }
                }

                EditorGUILayout.Space();

                Styles.Row(Styles.header, "Blocks");
                foreach (var block in context.activeChildrenWithImplicit)
                {
                    Styles.Row(Styles.cell, block.name, !context.children.Contains(block) ? "implicit" : "");
                }

                EditorGUILayout.Space();
            }
        }
    }