public override void OnSceneViewGUI() { Color color = Handles.color; Handles.color = ShapeModuleUI.s_ShapeGizmoColor; Matrix4x4 matrix = Handles.matrix; EditorGUI.BeginChangeCheck(); ParticleSystem[] particleSystems = this.m_ParticleSystemUI.m_ParticleSystems; for (int i = 0; i < particleSystems.Length; i++) { ParticleSystem particleSystem = particleSystems[i]; ParticleSystem.ShapeModule shape = particleSystem.shape; ParticleSystem.MainModule main = particleSystem.main; ParticleSystemShapeType shapeType = shape.shapeType; Matrix4x4 matrix4x = default(Matrix4x4); if (main.scalingMode == ParticleSystemScalingMode.Local) { matrix4x.SetTRS(particleSystem.transform.position, particleSystem.transform.rotation, particleSystem.transform.localScale); } else if (main.scalingMode == ParticleSystemScalingMode.Hierarchy) { matrix4x = particleSystem.transform.localToWorldMatrix; } else { matrix4x.SetTRS(particleSystem.transform.position, particleSystem.transform.rotation, particleSystem.transform.lossyScale); } bool flag = shapeType == ParticleSystemShapeType.Box || shapeType == ParticleSystemShapeType.BoxShell || shapeType == ParticleSystemShapeType.BoxEdge; Vector3 s = (!flag) ? shape.scale : Vector3.one; Matrix4x4 rhs = Matrix4x4.TRS(shape.position, Quaternion.Euler(shape.rotation), s); matrix4x *= rhs; Handles.matrix = matrix4x; if (shapeType == ParticleSystemShapeType.Sphere) { EditorGUI.BeginChangeCheck(); float radius = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, shape.radius, false); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Sphere Handle Change"); shape.radius = radius; } } else if (shapeType == ParticleSystemShapeType.Circle) { EditorGUI.BeginChangeCheck(); this.m_ArcHandle.radius = shape.radius; this.m_ArcHandle.angle = shape.arc; this.m_ArcHandle.SetColorWithRadiusHandle(Color.white, 0f); using (new Handles.DrawingScope(Handles.matrix * this.s_ArcHandleOffsetMatrix)) { this.m_ArcHandle.DrawHandle(); } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Circle Handle Change"); shape.radius = this.m_ArcHandle.radius; shape.arc = this.m_ArcHandle.angle; } } else if (shapeType == ParticleSystemShapeType.Hemisphere) { EditorGUI.BeginChangeCheck(); float radius2 = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, shape.radius, true); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Hemisphere Handle Change"); shape.radius = radius2; } } else if (shapeType == ParticleSystemShapeType.Cone) { EditorGUI.BeginChangeCheck(); Vector3 radiusAngleRange = new Vector3(shape.radius, shape.angle, main.startSpeedMultiplier); radiusAngleRange = Handles.ConeFrustrumHandle(Quaternion.identity, Vector3.zero, radiusAngleRange); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Cone Handle Change"); shape.radius = radiusAngleRange.x; shape.angle = radiusAngleRange.y; main.startSpeedMultiplier = radiusAngleRange.z; } } else if (shapeType == ParticleSystemShapeType.ConeVolume) { EditorGUI.BeginChangeCheck(); Vector3 radiusAngleRange2 = new Vector3(shape.radius, shape.angle, shape.length); radiusAngleRange2 = Handles.ConeFrustrumHandle(Quaternion.identity, Vector3.zero, radiusAngleRange2); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Cone Volume Handle Change"); shape.radius = radiusAngleRange2.x; shape.angle = radiusAngleRange2.y; shape.length = radiusAngleRange2.z; } } else if (shapeType == ParticleSystemShapeType.Box || shapeType == ParticleSystemShapeType.BoxShell || shapeType == ParticleSystemShapeType.BoxEdge) { EditorGUI.BeginChangeCheck(); this.m_BoxBoundsHandle.center = Vector3.zero; this.m_BoxBoundsHandle.size = shape.scale; this.m_BoxBoundsHandle.DrawHandle(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Box Handle Change"); shape.scale = this.m_BoxBoundsHandle.size; } } else if (shapeType == ParticleSystemShapeType.Donut) { EditorGUI.BeginChangeCheck(); this.m_ArcHandle.radius = shape.radius; this.m_ArcHandle.angle = shape.arc; this.m_ArcHandle.SetColorWithRadiusHandle(Color.white, 0f); this.m_ArcHandle.wireframeColor = Color.clear; using (new Handles.DrawingScope(Handles.matrix * this.s_ArcHandleOffsetMatrix)) { this.m_ArcHandle.DrawHandle(); } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Donut Handle Change"); shape.radius = this.m_ArcHandle.radius; shape.arc = this.m_ArcHandle.angle; } using (new Handles.DrawingScope(Handles.matrix * this.s_ArcHandleOffsetMatrix)) { float num = shape.arc % 360f; float angle = (Mathf.Abs(shape.arc) < 360f) ? num : 360f; Handles.DrawWireArc(new Vector3(0f, shape.donutRadius, 0f), Vector3.up, Vector3.forward, angle, shape.radius); Handles.DrawWireArc(new Vector3(0f, -shape.donutRadius, 0f), Vector3.up, Vector3.forward, angle, shape.radius); Handles.DrawWireArc(Vector3.zero, Vector3.up, Vector3.forward, angle, shape.radius + shape.donutRadius); Handles.DrawWireArc(Vector3.zero, Vector3.up, Vector3.forward, angle, shape.radius - shape.donutRadius); if (shape.arc != 360f) { Quaternion rotation = Quaternion.AngleAxis(shape.arc, Vector3.up); Vector3 center = rotation * Vector3.forward * shape.radius; Handles.DrawWireDisc(center, rotation * Vector3.right, shape.donutRadius); } } this.m_SphereBoundsHandle.axes = (PrimitiveBoundsHandle.Axes.X | PrimitiveBoundsHandle.Axes.Y); this.m_SphereBoundsHandle.radius = shape.donutRadius; this.m_SphereBoundsHandle.center = Vector3.zero; this.m_SphereBoundsHandle.SetColor(Color.white); float num2 = 90f; int num3 = Mathf.Max(1, (int)Mathf.Ceil(shape.arc / num2)); Matrix4x4 rhs2 = Matrix4x4.TRS(new Vector3(shape.radius, 0f, 0f), Quaternion.Euler(90f, 0f, 0f), Vector3.one); for (int j = 0; j < num3; j++) { EditorGUI.BeginChangeCheck(); using (new Handles.DrawingScope(Handles.matrix * (Matrix4x4.Rotate(Quaternion.Euler(0f, 0f, num2 * (float)j)) * rhs2))) { this.m_SphereBoundsHandle.DrawHandle(); } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Donut Radius Handle Change"); shape.donutRadius = this.m_SphereBoundsHandle.radius; } } } else if (shapeType == ParticleSystemShapeType.SingleSidedEdge) { EditorGUI.BeginChangeCheck(); float radius3 = Handles.DoSimpleEdgeHandle(Quaternion.identity, Vector3.zero, shape.radius); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Edge Handle Change"); shape.radius = radius3; } } else if (shapeType == ParticleSystemShapeType.Mesh) { Mesh mesh = shape.mesh; if (mesh) { bool wireframe = GL.wireframe; GL.wireframe = true; this.m_Material.SetPass(0); Graphics.DrawMeshNow(mesh, matrix4x); GL.wireframe = wireframe; } } } if (EditorGUI.EndChangeCheck()) { this.m_ParticleSystemUI.m_ParticleEffectUI.m_Owner.Repaint(); } Handles.color = color; Handles.matrix = matrix; }