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) { 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 (renderMode != RenderMode.None) { 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); 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) { 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); 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 (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); }
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) { EditorGUI.BeginChangeCheck(); int selectedIndex = (m_RenderAlignment.hasMultipleDifferentValues || m_RenderAlignment.intValue == (int)ParticleSystemRenderSpace.World) ? 0 : 1; selectedIndex = GUIPopup(s_Texts.alignedToDirectionSpace, selectedIndex, s_Texts.alignedToDirectionSpaces); if (EditorGUI.EndChangeCheck()) { m_RenderAlignment.intValue = (selectedIndex == 0) ? (int)ParticleSystemRenderSpace.World : (int)ParticleSystemRenderSpace.Local; } } 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); }