void OnGUI() { GUIContent[] shapeLabels = Enum.GetNames(typeof(ParticleSystemForceFieldShape)).Select(n => new GUIContent(n)).ToArray(); m_Shape = (ParticleSystemForceFieldShape)GUI.SelectionGrid(new Rect(25, 25, 400, 25), (int)m_Shape, shapeLabels, 4); float y = 80.0f; float spacing = 40.0f; GUI.Label(new Rect(25, y, 140, 30), "Start Range"); m_StartRange = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), m_StartRange, 0.0f, 2.0f); y += spacing; GUI.Label(new Rect(25, y, 140, 30), "End Range"); m_EndRange = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), m_EndRange, 2.0f, 3.0f); y += spacing; GUI.Label(new Rect(25, y, 140, 30), "Direction"); m_Direction.x = GUI.HorizontalSlider(new Rect(165, y + 5, 40, 30), m_Direction.x, -1.0f, 1.0f); m_Direction.y = GUI.HorizontalSlider(new Rect(210, y + 5, 40, 30), m_Direction.y, -1.0f, 1.0f); m_Direction.z = GUI.HorizontalSlider(new Rect(255, y + 5, 40, 30), m_Direction.z, -1.0f, 1.0f); y += spacing; GUI.Label(new Rect(25, y, 140, 30), "Gravity"); m_Gravity = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), m_Gravity, -0.05f, 0.05f); y += spacing; GUI.Label(new Rect(25, y, 140, 30), "Gravity Focus"); m_GravityFocus = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), m_GravityFocus, 0.0f, 1.0f); y += spacing; GUI.Label(new Rect(25, y, 140, 30), "Rotation Speed"); m_RotationSpeed = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), m_RotationSpeed, -10.0f, 10.0f); y += spacing; GUI.Label(new Rect(25, y, 140, 30), "Rotation Attraction"); m_RotationAttraction = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), m_RotationAttraction, 0.0f, 0.01f); y += spacing; GUI.Label(new Rect(25, y, 140, 30), "Rotation Randomness"); m_RotationRandomness.x = GUI.HorizontalSlider(new Rect(165, y + 5, 60, 30), m_RotationRandomness.x, 0.0f, 1.0f); m_RotationRandomness.y = GUI.HorizontalSlider(new Rect(230, y + 5, 60, 30), m_RotationRandomness.y, 0.0f, 1.0f); y += spacing; GUI.Label(new Rect(25, y, 140, 30), "Drag"); m_Drag = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), m_Drag, 0.0f, 20.0f); y += spacing; m_MultiplyDragByParticleSize = GUI.Toggle(new Rect(25, y, 220, 30), m_MultiplyDragByParticleSize, "Multiply Drag by Particle Size"); y += spacing; m_MultiplyDragByParticleVelocity = GUI.Toggle(new Rect(25, y, 220, 30), m_MultiplyDragByParticleVelocity, "Multiply Drag by Particle Velocity"); y += spacing; }
protected override void ReadFromImpl(object obj) { base.ReadFromImpl(obj); ParticleSystemForceField uo = (ParticleSystemForceField)obj; shape = uo.shape; startRange = uo.startRange; endRange = uo.endRange; length = uo.length; gravityFocus = uo.gravityFocus; rotationRandomness = uo.rotationRandomness; multiplyDragByParticleSize = uo.multiplyDragByParticleSize; multiplyDragByParticleVelocity = uo.multiplyDragByParticleVelocity; vectorField = ToID(uo.vectorField); directionX = uo.directionX; directionY = uo.directionY; directionZ = uo.directionZ; gravity = uo.gravity; rotationSpeed = uo.rotationSpeed; rotationAttraction = uo.rotationAttraction; drag = uo.drag; vectorFieldSpeed = uo.vectorFieldSpeed; vectorFieldAttraction = uo.vectorFieldAttraction; }
public static void DrawHandle(ParticleSystemForceField ff) { using (new Handles.DrawingScope(s_GizmoColor, ff.transform.localToWorldMatrix)) { ParticleSystemForceFieldShape forceShape = ff.shape; if (forceShape == ParticleSystemForceFieldShape.Sphere) { DrawSphere(s_EndRangeProperty, ff); if (ff.startRange > 0.0f) { DrawSphere(s_StartRangeProperty, ff); } if (ff.gravityFocus > 0.0f) { using (new Handles.DrawingScope(s_GizmoColor * s_GizmoFocusTint)) DrawSphere(s_GravityFocusProperty, ff, ff.endRange); } } else if (forceShape == ParticleSystemForceFieldShape.Hemisphere) { DrawHemisphere(s_EndRangeProperty, ff); if (ff.startRange > 0.0f) { DrawHemisphere(s_StartRangeProperty, ff); } if (ff.gravityFocus > 0.0f) { using (new Handles.DrawingScope(s_GizmoColor * s_GizmoFocusTint)) DrawHemisphere(s_GravityFocusProperty, ff, ff.endRange); } } else if (forceShape == ParticleSystemForceFieldShape.Cylinder) { DrawCylinder(s_EndRangeProperty, s_LengthProperty, ff); if (ff.startRange > 0.0f) { DrawCylinder(s_StartRangeProperty, s_LengthProperty, ff); } if (ff.gravityFocus > 0.0f) { using (new Handles.DrawingScope(s_GizmoColor * s_GizmoFocusTint)) DrawCylinder(s_GravityFocusProperty, s_LengthProperty, ff, ff.endRange); } } else if (forceShape == ParticleSystemForceFieldShape.Box) { DrawBox(s_EndRangeProperty, ff); if (ff.startRange > 0.0f) { DrawBox(s_StartRangeProperty, ff); } if (ff.gravityFocus > 0.0f) { using (new Handles.DrawingScope(s_GizmoColor * s_GizmoFocusTint)) DrawBox(s_GravityFocusProperty, ff, ff.endRange); } } } }