public static void DrawCone(VFXGizmo gizmo, TCone cone, ref Extremities extremities, IProperty <Vector3> centerProperty, IProperty <Vector3> anglesProperty, IProperty <Vector3> scaleProperty, IProperty <float> baseRadiusProperty, IProperty <float> topRadiusProperty, IProperty <float> heightProperty, float baseRadiusScreen, float topRadiusScreen) { var center = cone.transform.position; var scale = cone.transform.scale; var angles = cone.transform.angles; var baseRadius = cone.baseRadius; var topRadius = cone.topRadius; var height = cone.height; gizmo.PositionGizmo(center, angles, centerProperty, false); gizmo.RotationGizmo(center, angles, anglesProperty, false); gizmo.ScaleGizmo(center, angles, scale, scaleProperty, false); using (new Handles.DrawingScope(Handles.matrix * cone.transform)) { if (baseRadiusScreen > 2 && baseRadiusProperty.isEditable) { for (int i = extremities.extremities.Count / 2; i < extremities.extremities.Count && (i - extremities.extremities.Count / 2) < extremities.visibleCount; ++i) { EditorGUI.BeginChangeCheck(); var pos = extremities.extremities[i]; var result = Handles.Slider(s_ExtremitiesNames[i], pos, pos - extremities.bottomCap, handleSize * HandleUtility.GetHandleSize(pos), CustomCubeHandleCap, 0); if (EditorGUI.EndChangeCheck()) { baseRadiusProperty.SetValue(result.magnitude); } } } if (topRadiusScreen > 2 && topRadiusProperty.isEditable) { for (int i = 0; i < extremities.extremities.Count / 2 && i < extremities.visibleCount; ++i) { EditorGUI.BeginChangeCheck(); var pos = extremities.extremities[i]; var dir = pos - extremities.topCap; var result = Handles.Slider(s_ExtremitiesNames[i], pos, dir, handleSize * HandleUtility.GetHandleSize(pos), CustomCubeHandleCap, 0); if (EditorGUI.EndChangeCheck()) { topRadiusProperty.SetValue((result - extremities.topCap).magnitude); } } } if (heightProperty.isEditable) { EditorGUI.BeginChangeCheck(); var result = Handles.Slider(s_HeightCapName, extremities.topCap, Vector3.up, handleSize * HandleUtility.GetHandleSize(extremities.topCap), CustomCubeHandleCap, 0); if (EditorGUI.EndChangeCheck()) { heightProperty.SetValue(result.magnitude); } } } }
public static void DrawCone(Cone cone, VFXGizmo gizmo, ref Extremities extremities, IProperty <Vector3> centerProperty, IProperty <float> radius0Property, IProperty <float> radius1Property, IProperty <float> heightProperty, float radius0Screen, float radius1Screen) { gizmo.PositionGizmo(cone.center, centerProperty, true); using (new Handles.DrawingScope(Handles.matrix * Matrix4x4.Translate(cone.center))) { if (radius0Screen > 2 && radius0Property.isEditable) { for (int i = extremities.extremities.Count / 2; i < extremities.extremities.Count; ++i) { EditorGUI.BeginChangeCheck(); Vector3 pos = extremities.extremities[i]; Vector3 result = Handles.Slider(pos, pos - extremities.bottomCap, (i - extremities.extremities.Count / 2) < extremities.visibleCount ? handleSize * HandleUtility.GetHandleSize(pos) : 0, Handles.CubeHandleCap, 0); if (EditorGUI.EndChangeCheck()) { radius0Property.SetValue(result.magnitude); } } } if (radius1Screen > 2 && radius1Property.isEditable) { for (int i = 0; i < extremities.extremities.Count / 2; ++i) { EditorGUI.BeginChangeCheck(); Vector3 pos = extremities.extremities[i]; Vector3 dir = pos - extremities.topCap; Vector3 result = Handles.Slider(pos, dir, i < extremities.visibleCount ? handleSize * HandleUtility.GetHandleSize(pos) : 0, Handles.CubeHandleCap, 0); if (EditorGUI.EndChangeCheck()) { radius1Property.SetValue((result - extremities.topCap).magnitude); } } } if (heightProperty.isEditable) { EditorGUI.BeginChangeCheck(); Vector3 result = Handles.Slider(extremities.topCap, Vector3.up, handleSize * HandleUtility.GetHandleSize(extremities.topCap), Handles.CubeHandleCap, 0); if (EditorGUI.EndChangeCheck()) { heightProperty.SetValue(result.magnitude); } } } }