override public void OnInspectorGUI(InitialModuleUI initial)
        {
            EditorGUI.BeginChangeCheck();
            RenderMode renderMode        = (RenderMode)GUIPopup(s_Texts.renderMode, m_RenderMode, s_Texts.particleTypes);
            bool       renderModeChanged = EditorGUI.EndChangeCheck();

            if (!m_RenderMode.hasMultipleDifferentValues)
            {
                if (renderMode == RenderMode.Mesh)
                {
                    EditorGUI.indentLevel++;
                    DoListOfMeshesGUI();
                    EditorGUI.indentLevel--;

                    if (renderModeChanged && m_Meshes[0].objectReferenceInstanceIDValue == 0 && !m_Meshes[0].hasMultipleDifferentValues)
                    {
                        m_Meshes[0].objectReferenceValue = Resources.GetBuiltinResource(typeof(Mesh), "Cube.fbx");
                    }
                }
                else if (renderMode == RenderMode.Stretch3D)
                {
                    EditorGUI.indentLevel++;
                    GUIFloat(s_Texts.cameraSpeedScale, m_CameraVelocityScale);
                    GUIFloat(s_Texts.speedScale, m_VelocityScale);
                    GUIFloat(s_Texts.lengthScale, m_LengthScale);
                    EditorGUI.indentLevel--;
                }

                if (renderMode != RenderMode.None)
                {
                    if (renderMode != RenderMode.Mesh)
                    {
                        GUIFloat(s_Texts.normalDirection, m_NormalDirection);
                    }

                    if (m_Material != null) // The renderer's material list could be empty
                    {
                        GUIObject(s_Texts.material, m_Material);
                    }
                }
            }

            if (m_TrailMaterial != null) // The renderer's material list could be empty
            {
                GUIObject(s_Texts.trailMaterial, m_TrailMaterial);
            }

            if (renderMode != RenderMode.None)
            {
                if (!m_RenderMode.hasMultipleDifferentValues)
                {
                    GUIPopup(s_Texts.sortMode, m_SortMode, s_Texts.sortTypes);
                    GUIFloat(s_Texts.sortingFudge, m_SortingFudge);

                    if (renderMode != RenderMode.Mesh)
                    {
                        GUIFloat(s_Texts.minParticleSize, m_MinParticleSize);
                        GUIFloat(s_Texts.maxParticleSize, m_MaxParticleSize);
                    }

                    if (renderMode == RenderMode.Billboard || renderMode == RenderMode.Mesh)
                    {
                        bool anyAligntoDirection = m_ParticleSystemUI.m_ParticleSystems.FirstOrDefault(o => o.shape.alignToDirection) != null;
                        if (anyAligntoDirection)
                        {
                            using (new EditorGUI.DisabledScope(true))
                            {
                                GUIPopup(s_Texts.space, 0, s_Texts.localSpace); // force to "Local"
                            }

                            GUIContent info = EditorGUIUtility.TrTextContent("Using Align to Direction in the Shape Module forces the system to be rendered using Local Render Alignment.");
                            EditorGUILayout.HelpBox(info.text, MessageType.Info, true);
                        }
                        else
                        {
                            GUIPopup(s_Texts.space, m_RenderAlignment, s_Texts.spaces);
                        }
                    }

                    if (renderMode == RenderMode.Mesh)
                    {
                        GUIToggle(s_Texts.enableGPUInstancing, m_EnableGPUInstancing);
                    }
                }

                GUIVector3Field(s_Texts.pivot, m_Pivot);

                EditorGUI.BeginChangeCheck();
                s_VisualizePivot = GUIToggle(s_Texts.visualizePivot, s_VisualizePivot);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorPrefs.SetBool("VisualizePivot", s_VisualizePivot);
                }

                GUIPopup(s_Texts.maskingMode, m_MaskInteraction, s_Texts.maskInteractions);

                if (GUIToggle(s_Texts.useCustomVertexStreams, m_UseCustomVertexStreams))
                {
                    DoVertexStreamsGUI(renderMode);
                }
            }

            EditorGUILayout.Space();

            GUIPopup(s_Texts.castShadows, m_CastShadows, EditorGUIUtility.TempContent(m_CastShadows.enumDisplayNames));

            if (SupportedRenderingFeatures.active.rendererSupportsReceiveShadows)
            {
                // Disable ReceiveShadows options for Deferred rendering path
                if (SceneView.IsUsingDeferredRenderingPath())
                {
                    using (new EditorGUI.DisabledScope(true)) { GUIToggle(s_Texts.receiveShadows, true); }
                }
                else
                {
                    GUIToggle(s_Texts.receiveShadows, m_ReceiveShadows);
                }
            }

            if (SupportedRenderingFeatures.active.rendererSupportsMotionVectors)
            {
                GUIPopup(s_Texts.motionVectors, m_MotionVectors, s_Texts.motionVectorOptions);
            }

            GUISortingLayerField(s_Texts.sortingLayer, m_SortingLayerID);
            GUIInt(s_Texts.sortingOrder, m_SortingOrder);

            List <ParticleSystemRenderer> renderers = new List <ParticleSystemRenderer>();

            foreach (ParticleSystem ps in m_ParticleSystemUI.m_ParticleSystems)
            {
                renderers.Add(ps.GetComponent <ParticleSystemRenderer>());
            }
            var renderersArray = renderers.ToArray();

            m_Probes.OnGUI(renderersArray, renderers.FirstOrDefault(), true);

            RendererEditorBase.RenderRenderingLayer(m_RenderingLayerMask, serializedObject.targetObject as Renderer, renderersArray, true);
        }
示例#2
0
        public override void OnInspectorGUI(InitialModuleUI initial)
        {
            EditorGUI.BeginChangeCheck();
            RendererModuleUI.RenderMode renderMode = (RendererModuleUI.RenderMode)ModuleUI.GUIPopup(RendererModuleUI.s_Texts.renderMode, this.m_RenderMode, RendererModuleUI.s_Texts.particleTypes, new GUILayoutOption[0]);
            bool flag = EditorGUI.EndChangeCheck();

            if (!this.m_RenderMode.hasMultipleDifferentValues)
            {
                if (renderMode == RendererModuleUI.RenderMode.Mesh)
                {
                    EditorGUI.indentLevel++;
                    this.DoListOfMeshesGUI();
                    EditorGUI.indentLevel--;
                    if (flag && this.m_Meshes[0].objectReferenceInstanceIDValue == 0 && !this.m_Meshes[0].hasMultipleDifferentValues)
                    {
                        this.m_Meshes[0].objectReferenceValue = Resources.GetBuiltinResource(typeof(Mesh), "Cube.fbx");
                    }
                }
                else if (renderMode == RendererModuleUI.RenderMode.Stretch3D)
                {
                    EditorGUI.indentLevel++;
                    ModuleUI.GUIFloat(RendererModuleUI.s_Texts.cameraSpeedScale, this.m_CameraVelocityScale, new GUILayoutOption[0]);
                    ModuleUI.GUIFloat(RendererModuleUI.s_Texts.speedScale, this.m_VelocityScale, new GUILayoutOption[0]);
                    ModuleUI.GUIFloat(RendererModuleUI.s_Texts.lengthScale, this.m_LengthScale, new GUILayoutOption[0]);
                    EditorGUI.indentLevel--;
                }
                if (renderMode != RendererModuleUI.RenderMode.None)
                {
                    if (renderMode != RendererModuleUI.RenderMode.Mesh)
                    {
                        ModuleUI.GUIFloat(RendererModuleUI.s_Texts.normalDirection, this.m_NormalDirection, new GUILayoutOption[0]);
                    }
                    if (this.m_Material != null)
                    {
                        ModuleUI.GUIObject(RendererModuleUI.s_Texts.material, this.m_Material, new GUILayoutOption[0]);
                    }
                }
            }
            if (this.m_TrailMaterial != null)
            {
                ModuleUI.GUIObject(RendererModuleUI.s_Texts.trailMaterial, this.m_TrailMaterial, new GUILayoutOption[0]);
            }
            if (renderMode != RendererModuleUI.RenderMode.None)
            {
                if (!this.m_RenderMode.hasMultipleDifferentValues)
                {
                    ModuleUI.GUIPopup(RendererModuleUI.s_Texts.sortMode, this.m_SortMode, RendererModuleUI.s_Texts.sortTypes, new GUILayoutOption[0]);
                    ModuleUI.GUIFloat(RendererModuleUI.s_Texts.sortingFudge, this.m_SortingFudge, new GUILayoutOption[0]);
                    if (renderMode != RendererModuleUI.RenderMode.Mesh)
                    {
                        ModuleUI.GUIFloat(RendererModuleUI.s_Texts.minParticleSize, this.m_MinParticleSize, new GUILayoutOption[0]);
                        ModuleUI.GUIFloat(RendererModuleUI.s_Texts.maxParticleSize, this.m_MaxParticleSize, new GUILayoutOption[0]);
                    }
                    if (renderMode == RendererModuleUI.RenderMode.Billboard || renderMode == RendererModuleUI.RenderMode.Mesh)
                    {
                        bool flag2 = this.m_ParticleSystemUI.m_ParticleSystems.FirstOrDefault((ParticleSystem o) => o.shape.alignToDirection) != null;
                        if (flag2)
                        {
                            using (new EditorGUI.DisabledScope(true))
                            {
                                ModuleUI.GUIPopup(RendererModuleUI.s_Texts.space, 0, RendererModuleUI.s_Texts.localSpace, new GUILayoutOption[0]);
                            }
                            GUIContent gUIContent = EditorGUIUtility.TrTextContent("Using Align to Direction in the Shape Module forces the system to be rendered using Local Render Alignment.", null, null);
                            EditorGUILayout.HelpBox(gUIContent.text, MessageType.Info, true);
                        }
                        else
                        {
                            ModuleUI.GUIPopup(RendererModuleUI.s_Texts.space, this.m_RenderAlignment, RendererModuleUI.s_Texts.spaces, new GUILayoutOption[0]);
                        }
                    }
                    if (renderMode == RendererModuleUI.RenderMode.Mesh)
                    {
                        ModuleUI.GUIToggle(RendererModuleUI.s_Texts.enableGPUInstancing, this.m_EnableGPUInstancing, new GUILayoutOption[0]);
                    }
                }
                ModuleUI.GUIVector3Field(RendererModuleUI.s_Texts.pivot, this.m_Pivot, new GUILayoutOption[0]);
                EditorGUI.BeginChangeCheck();
                RendererModuleUI.s_VisualizePivot = ModuleUI.GUIToggle(RendererModuleUI.s_Texts.visualizePivot, RendererModuleUI.s_VisualizePivot, new GUILayoutOption[0]);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorPrefs.SetBool("VisualizePivot", RendererModuleUI.s_VisualizePivot);
                }
                ModuleUI.GUIPopup(RendererModuleUI.s_Texts.maskingMode, this.m_MaskInteraction, RendererModuleUI.s_Texts.maskInteractions, new GUILayoutOption[0]);
                if (ModuleUI.GUIToggle(RendererModuleUI.s_Texts.useCustomVertexStreams, this.m_UseCustomVertexStreams, new GUILayoutOption[0]))
                {
                    this.DoVertexStreamsGUI(renderMode);
                }
            }
            EditorGUILayout.Space();
            ModuleUI.GUIPopup(RendererModuleUI.s_Texts.castShadows, this.m_CastShadows, EditorGUIUtility.TempContent(this.m_CastShadows.enumDisplayNames), new GUILayoutOption[0]);
            if (SupportedRenderingFeatures.active.rendererSupportsReceiveShadows)
            {
                if (SceneView.IsUsingDeferredRenderingPath())
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        ModuleUI.GUIToggle(RendererModuleUI.s_Texts.receiveShadows, true, new GUILayoutOption[0]);
                    }
                }
                else
                {
                    ModuleUI.GUIToggle(RendererModuleUI.s_Texts.receiveShadows, this.m_ReceiveShadows, new GUILayoutOption[0]);
                }
            }
            if (SupportedRenderingFeatures.active.rendererSupportsMotionVectors)
            {
                ModuleUI.GUIPopup(RendererModuleUI.s_Texts.motionVectors, this.m_MotionVectors, RendererModuleUI.s_Texts.motionVectorOptions, new GUILayoutOption[0]);
            }
            ModuleUI.GUISortingLayerField(RendererModuleUI.s_Texts.sortingLayer, this.m_SortingLayerID, new GUILayoutOption[0]);
            ModuleUI.GUIInt(RendererModuleUI.s_Texts.sortingOrder, this.m_SortingOrder, new GUILayoutOption[0]);
            List <ParticleSystemRenderer> list = new List <ParticleSystemRenderer>();

            ParticleSystem[] particleSystems = this.m_ParticleSystemUI.m_ParticleSystems;
            for (int i = 0; i < particleSystems.Length; i++)
            {
                ParticleSystem particleSystem = particleSystems[i];
                list.Add(particleSystem.GetComponent <ParticleSystemRenderer>());
            }
            ParticleSystemRenderer[] array = list.ToArray();
            this.m_Probes.OnGUI(array, list.FirstOrDefault <ParticleSystemRenderer>(), true);
            RendererEditorBase.RenderRenderingLayer(this.m_RenderingLayerMask, base.serializedObject.targetObject as Renderer, array, true);
        }
        override public void OnInspectorGUI(InitialModuleUI initial)
        {
            var renderer = serializedObject.targetObject as Renderer;

            EditorGUI.BeginChangeCheck();
            RenderMode renderMode        = (RenderMode)GUIPopup(s_Texts.renderMode, m_RenderMode, s_Texts.particleTypes);
            bool       renderModeChanged = EditorGUI.EndChangeCheck();

            if (!m_RenderMode.hasMultipleDifferentValues)
            {
                if (renderMode == RenderMode.Mesh)
                {
                    GUIPopup(s_Texts.meshDistribution, m_MeshDistribution, s_Texts.meshDistributionOptions);
                    DoListOfMeshesGUI();

                    if (renderModeChanged && m_Meshes[0].objectReferenceInstanceIDValue == 0 && !m_Meshes[0].hasMultipleDifferentValues)
                    {
                        m_Meshes[0].objectReferenceValue = Resources.GetBuiltinResource(typeof(Mesh), "Cube.fbx");
                    }
                }
                else if (renderMode == RenderMode.Stretch3D)
                {
                    EditorGUI.indentLevel++;
                    GUIFloat(s_Texts.cameraSpeedScale, m_CameraVelocityScale);
                    GUIFloat(s_Texts.speedScale, m_VelocityScale);
                    GUIFloat(s_Texts.lengthScale, m_LengthScale);
                    GUIToggle(s_Texts.freeformStretching, m_FreeformStretching);
                    if (m_FreeformStretching.boolValue && !m_FreeformStretching.hasMultipleDifferentValues)
                    {
                        GUIToggle(s_Texts.rotateWithStretchDirection, m_RotateWithStretchDirection);
                    }
                    else
                    {
                        using (new EditorGUI.DisabledScope(true))
                        {
                            GUIToggle(s_Texts.rotateWithStretchDirection, true);
                        }
                    }
                    EditorGUI.indentLevel--;
                }

                if (renderMode != RenderMode.None)
                {
                    if (renderMode != RenderMode.Mesh)
                    {
                        GUIFloat(s_Texts.normalDirection, m_NormalDirection);
                    }
                }
            }

            if (renderMode != RenderMode.None)
            {
                if (m_Material != null) // The renderer's material list could be empty
                {
                    GUIObject(s_Texts.material, m_Material);
                }
            }

            var trailMaterial = serializedObject.FindProperty("m_Materials.Array.data[1]"); // Optional - may fail

            if (trailMaterial != null)                                                      // Only show if the system has a second material slot
            {
                GUIObject(s_Texts.trailMaterial, trailMaterial);
            }

            if (renderMode != RenderMode.None)
            {
                if (!m_RenderMode.hasMultipleDifferentValues)
                {
                    GUIPopup(s_Texts.sortMode, m_SortMode, s_Texts.sortTypes);
                    if (renderer != null && SortingGroup.invalidSortingGroupID != renderer.sortingGroupID)
                    {
                        using (new EditorGUI.DisabledScope(true))
                            GUIFloat(s_Texts.sortingFudgeDisabledDueToSortingGroup, m_SortingFudge);
                    }
                    else
                    {
                        GUIFloat(s_Texts.sortingFudge, m_SortingFudge);
                    }

                    if (renderMode != RenderMode.Mesh)
                    {
                        GUIFloat(s_Texts.minParticleSize, m_MinParticleSize);
                        GUIFloat(s_Texts.maxParticleSize, m_MaxParticleSize);
                    }

                    if (renderMode == RenderMode.Billboard || renderMode == RenderMode.Mesh)
                    {
                        bool anyAlignToDirection = m_ParticleSystemUI.m_ParticleSystems.FirstOrDefault(o => o.shape.enabled && o.shape.alignToDirection) != null;
                        if (anyAlignToDirection)
                        {
                            using (new EditorGUI.DisabledScope(true))
                            {
                                GUIPopup(s_Texts.space, 0, s_Texts.localSpace); // force to "Local"
                            }

                            GUIContent info = EditorGUIUtility.TrTextContent("Using Align to Direction in the Shape Module forces the system to be rendered using Local Render Alignment.");
                            EditorGUILayout.HelpBox(info.text, MessageType.Info, true);
                        }
                        else
                        {
                            GUIPopup(s_Texts.space, m_RenderAlignment, s_Texts.spaces);
                        }
                    }

                    if (renderMode == RenderMode.Mesh)
                    {
                        GUIVector3Field(s_Texts.flipMeshes, m_Flip);
                    }
                    else
                    {
                        GUIVector3Field(s_Texts.flip, m_Flip);
                    }

                    if (renderMode == RenderMode.Billboard)
                    {
                        GUIToggle(s_Texts.allowRoll, m_AllowRoll);
                    }

                    if (renderMode == RenderMode.Mesh && SupportedRenderingFeatures.active.particleSystemInstancing)
                    {
                        GUIToggle(s_Texts.enableGPUInstancing, m_EnableGPUInstancing);

                        if (!m_ParticleSystemUI.multiEdit && m_EnableGPUInstancing.boolValue)
                        {
                            Material materialAsset      = m_Material?.objectReferenceValue as Material;
                            Material trailMaterialAsset = trailMaterial?.objectReferenceValue as Material;

                            if (materialAsset != null && trailMaterialAsset != null)
                            {
                                if (trailMaterialAsset.shader == materialAsset.shader)
                                {
                                    if (ShaderUtil.HasProceduralInstancing(materialAsset.shader))
                                    {
                                        EditorGUILayout.HelpBox(s_Texts.meshGPUInstancingTrailsWarning.text, MessageType.Error, true);
                                    }
                                }
                            }
                        }
                    }
                }

                GUIVector3Field(s_Texts.pivot, m_Pivot);

                if (EditorGUIUtility.comparisonViewMode == EditorGUIUtility.ComparisonViewMode.None)
                {
                    EditorGUI.BeginChangeCheck();
                    s_VisualizePivot = GUIToggle(s_Texts.visualizePivot, s_VisualizePivot);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorPrefs.SetBool("VisualizePivot", s_VisualizePivot);
                    }
                }

                GUIPopup(s_Texts.maskingMode, m_MaskInteraction, s_Texts.maskInteractions);
                GUIToggle(s_Texts.applyActiveColorSpace, m_ApplyActiveColorSpace);

                if (GUIToggle(s_Texts.useCustomVertexStreams, m_UseCustomVertexStreams))
                {
                    DoVertexStreamsGUI(renderMode);
                }
            }

            EditorGUILayout.Space();

            GUIPopup(s_Texts.castShadows, m_CastShadows, EditorGUIUtility.TempContent(m_CastShadows.enumDisplayNames));

            if (m_CastShadows.hasMultipleDifferentValues || m_CastShadows.intValue != 0)
            {
                RenderPipelineAsset srpAsset = GraphicsSettings.currentRenderPipeline;
                if (srpAsset != null)
                {
                    GUIToggle(s_Texts.staticShadowCaster, m_StaticShadowCaster);
                }
            }

            if (SupportedRenderingFeatures.active.receiveShadows)
            {
                // Disable ReceiveShadows options for Deferred rendering path
                if (SceneView.IsUsingDeferredRenderingPath())
                {
                    using (new EditorGUI.DisabledScope(true)) { GUIToggle(s_Texts.receiveShadows, true); }
                }
                else
                {
                    GUIToggle(s_Texts.receiveShadows, m_ReceiveShadows);
                }
            }

            if (renderMode != RenderMode.Mesh)
            {
                GUIFloat(s_Texts.shadowBias, m_ShadowBias);
            }

            if (SupportedRenderingFeatures.active.motionVectors)
            {
                GUIPopup(s_Texts.motionVectors, m_MotionVectors, s_Texts.motionVectorOptions);
            }

            GUISortingLayerField(s_Texts.sortingLayer, m_SortingLayerID);
            GUIInt(s_Texts.sortingOrder, m_SortingOrder);

            List <ParticleSystemRenderer> renderers = new List <ParticleSystemRenderer>();

            foreach (ParticleSystem ps in m_ParticleSystemUI.m_ParticleSystems)
            {
                renderers.Add(ps.GetComponent <ParticleSystemRenderer>());
            }
            var renderersArray = renderers.ToArray();

            m_Probes.OnGUI(renderersArray, renderers.FirstOrDefault(), true);

            RendererEditorBase.DrawRenderingLayer(m_RenderingLayerMask, renderer, renderersArray, true);
            RendererEditorBase.DrawRendererPriority(m_RendererPriority, true);
        }
示例#4
0
 protected void RenderRenderingLayer()
 {
     RendererEditorBase.RenderRenderingLayer(this.m_RenderingLayerMask, base.target as Renderer, base.targets.ToArray <UnityEngine.Object>(), false);
 }