public override void OnSceneGUI(ParticleSystem system, InitialModuleUI initial) { Color color = Handles.color; Handles.color = s_ShapeGizmoColor; Matrix4x4 matrix = Handles.matrix; EditorGUI.BeginChangeCheck(); int intValue = this.m_Type.intValue; Matrix4x4 transform = new Matrix4x4(); float x = (intValue != 6) ? 1f : this.m_MeshScale.floatValue; if (system.main.scalingMode == ParticleSystemScalingMode.Local) { transform.SetTRS(system.transform.position, system.transform.rotation, (Vector3)(system.transform.localScale * x)); } else if (system.main.scalingMode == ParticleSystemScalingMode.Hierarchy) { transform = system.transform.localToWorldMatrix * Matrix4x4.Scale(new Vector3(x, x, x)); } else { transform.SetTRS(system.transform.position, system.transform.rotation, (Vector3)(system.transform.lossyScale * x)); } Handles.matrix = transform; switch (intValue) { case 0: case 1: this.m_Radius.floatValue = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, this.m_Radius.floatValue, false); break; } if ((intValue == 10) || (intValue == 11)) { float floatValue = this.m_Radius.floatValue; float arc = this.m_Arc.floatValue; Handles.DoSimpleRadiusArcHandleXY(Quaternion.identity, Vector3.zero, ref floatValue, ref arc); this.m_Radius.floatValue = floatValue; this.m_Arc.floatValue = arc; } else if ((intValue == 2) || (intValue == 3)) { this.m_Radius.floatValue = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, this.m_Radius.floatValue, true); } else if ((intValue == 4) || (intValue == 7)) { Vector3 radiusAngleRange = new Vector3(this.m_Radius.floatValue, this.m_Angle.floatValue, initial.m_Speed.scalar.floatValue); radiusAngleRange = Handles.ConeFrustrumHandle(Quaternion.identity, Vector3.zero, radiusAngleRange); this.m_Radius.floatValue = radiusAngleRange.x; this.m_Angle.floatValue = radiusAngleRange.y; initial.m_Speed.scalar.floatValue = radiusAngleRange.z; } else if ((intValue == 8) || (intValue == 9)) { Vector3 vector2 = new Vector3(this.m_Radius.floatValue, this.m_Angle.floatValue, this.m_Length.floatValue); vector2 = Handles.ConeFrustrumHandle(Quaternion.identity, Vector3.zero, vector2); this.m_Radius.floatValue = vector2.x; this.m_Angle.floatValue = vector2.y; this.m_Length.floatValue = vector2.z; } else if (((intValue == 5) || (intValue == 15)) || (intValue == 0x10)) { Vector3 zero = Vector3.zero; Vector3 size = new Vector3(this.m_BoxX.floatValue, this.m_BoxY.floatValue, this.m_BoxZ.floatValue); if (this.m_BoxEditor.OnSceneGUI(transform, s_ShapeGizmoColor, false, ref zero, ref size)) { this.m_BoxX.floatValue = size.x; this.m_BoxY.floatValue = size.y; this.m_BoxZ.floatValue = size.z; } } else if (intValue == 12) { this.m_Radius.floatValue = Handles.DoSimpleEdgeHandle(Quaternion.identity, Vector3.zero, this.m_Radius.floatValue); } else if (intValue == 6) { Mesh objectReferenceValue = (Mesh)this.m_Mesh.objectReferenceValue; if (objectReferenceValue != null) { bool wireframe = GL.wireframe; GL.wireframe = true; this.m_Material.SetPass(0); Graphics.DrawMeshNow(objectReferenceValue, transform); GL.wireframe = wireframe; } } if (EditorGUI.EndChangeCheck()) { base.m_ParticleSystemUI.m_ParticleEffectUI.m_Owner.Repaint(); } Handles.color = color; Handles.matrix = matrix; }
public override void OnSceneGUI(ParticleSystem s, InitialModuleUI initial) { Color color = Handles.color; Handles.color = ShapeModuleUI.s_ShapeGizmoColor; Matrix4x4 matrix = Handles.matrix; Matrix4x4 matrix4x = default(Matrix4x4); matrix4x.SetTRS(s.transform.position, s.transform.rotation, s.transform.lossyScale); Handles.matrix = matrix4x; EditorGUI.BeginChangeCheck(); int intValue = this.m_Type.intValue; if (intValue == 0 || intValue == 1) { this.m_Radius.floatValue = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, this.m_Radius.floatValue, false); } if (intValue == 10 || intValue == 11) { float floatValue = this.m_Radius.floatValue; float floatValue2 = this.m_Arc.floatValue; Handles.DoSimpleRadiusArcHandleXY(Quaternion.identity, Vector3.zero, ref floatValue, ref floatValue2); this.m_Radius.floatValue = floatValue; this.m_Arc.floatValue = floatValue2; } else if (intValue == 2 || intValue == 3) { this.m_Radius.floatValue = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, this.m_Radius.floatValue, true); } else if (intValue == 4 || intValue == 7) { Vector3 radiusAngleRange = new Vector3(this.m_Radius.floatValue, this.m_Angle.floatValue, initial.m_Speed.scalar.floatValue); radiusAngleRange = Handles.ConeFrustrumHandle(Quaternion.identity, Vector3.zero, radiusAngleRange); this.m_Radius.floatValue = radiusAngleRange.x; this.m_Angle.floatValue = radiusAngleRange.y; initial.m_Speed.scalar.floatValue = radiusAngleRange.z; } else if (intValue == 8 || intValue == 9) { Vector3 radiusAngleRange2 = new Vector3(this.m_Radius.floatValue, this.m_Angle.floatValue, this.m_Length.floatValue); radiusAngleRange2 = Handles.ConeFrustrumHandle(Quaternion.identity, Vector3.zero, radiusAngleRange2); this.m_Radius.floatValue = radiusAngleRange2.x; this.m_Angle.floatValue = radiusAngleRange2.y; this.m_Length.floatValue = radiusAngleRange2.z; } else if (intValue == 5) { Vector3 zero = Vector3.zero; Vector3 vector = new Vector3(this.m_BoxX.floatValue, this.m_BoxY.floatValue, this.m_BoxZ.floatValue); if (this.m_BoxEditor.OnSceneGUI(matrix4x, ShapeModuleUI.s_ShapeGizmoColor, false, ref zero, ref vector)) { this.m_BoxX.floatValue = vector.x; this.m_BoxY.floatValue = vector.y; this.m_BoxZ.floatValue = vector.z; } } else if (intValue == 12) { this.m_Radius.floatValue = Handles.DoSimpleEdgeHandle(Quaternion.identity, Vector3.zero, this.m_Radius.floatValue); } else if (intValue == 6) { Mesh mesh = (Mesh)this.m_Mesh.objectReferenceValue; if (mesh) { bool wireframe = GL.wireframe; GL.wireframe = true; this.m_Material.SetPass(0); Graphics.DrawMeshNow(mesh, s.transform.localToWorldMatrix); GL.wireframe = wireframe; } } if (EditorGUI.EndChangeCheck()) { this.m_ParticleSystemUI.m_ParticleEffectUI.m_Owner.Repaint(); } Handles.color = color; Handles.matrix = matrix; }
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 matrix2 = default(Matrix4x4); float num = (shapeType != ParticleSystemShapeType.Mesh) ? 1f : shape.meshScale; if (main.scalingMode == ParticleSystemScalingMode.Local) { matrix2.SetTRS(particleSystem.transform.position, particleSystem.transform.rotation, particleSystem.transform.localScale * num); } else if (main.scalingMode == ParticleSystemScalingMode.Hierarchy) { matrix2 = particleSystem.transform.localToWorldMatrix * Matrix4x4.Scale(new Vector3(num, num, num)); } else { matrix2.SetTRS(particleSystem.transform.position, particleSystem.transform.rotation, particleSystem.transform.lossyScale * num); } Handles.matrix = matrix2; if (shapeType == ParticleSystemShapeType.Sphere || shapeType == ParticleSystemShapeType.SphereShell) { 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 || shapeType == ParticleSystemShapeType.CircleEdge) { EditorGUI.BeginChangeCheck(); float radius2 = shape.radius; float arc = shape.arc; Handles.DoSimpleRadiusArcHandleXY(Quaternion.identity, Vector3.zero, ref radius2, ref arc); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Circle Handle Change"); shape.radius = radius2; shape.arc = arc; } } else if (shapeType == ParticleSystemShapeType.Hemisphere || shapeType == ParticleSystemShapeType.HemisphereShell) { EditorGUI.BeginChangeCheck(); float radius3 = Handles.DoSimpleRadiusHandle(Quaternion.identity, Vector3.zero, shape.radius, true); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Hemisphere Handle Change"); shape.radius = radius3; } } else if (shapeType == ParticleSystemShapeType.Cone || shapeType == ParticleSystemShapeType.ConeShell) { 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 || shapeType == ParticleSystemShapeType.ConeVolumeShell) { 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.box; this.m_BoxBoundsHandle.DrawHandle(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Box Handle Change"); shape.box = this.m_BoxBoundsHandle.size; } } else if (shapeType == ParticleSystemShapeType.SingleSidedEdge) { EditorGUI.BeginChangeCheck(); float radius4 = Handles.DoSimpleEdgeHandle(Quaternion.identity, Vector3.zero, shape.radius); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(particleSystem, "Edge Handle Change"); shape.radius = radius4; } } 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, matrix2); GL.wireframe = wireframe; } } } if (EditorGUI.EndChangeCheck()) { this.m_ParticleSystemUI.m_ParticleEffectUI.m_Owner.Repaint(); } Handles.color = color; Handles.matrix = matrix; }