void OnSceneGUI() { if (light) { Transform lTransform = light.transform; Vector3 oldPoint = lTransform.TransformPoint(new Vector3(light.LightRadius, 0, 0)); float size = HandleUtility.GetHandleSize(oldPoint); Undo.RecordObject(light, "Move Light Radius Point"); Vector3 newPoint = Handles.FreeMoveHandle( oldPoint, Quaternion.identity, size * 0.05f, pointSnap, Handles.DotCap); if (oldPoint != newPoint) { Undo.RecordObject(light, "resize radiusLight"); light.LightRadius = (lTransform.InverseTransformPoint(newPoint).magnitude); light.Rebuild(); } Vector3 oldPoint2 = lTransform.TransformPoint(new Vector3(-light.LightRadius, 0, 0)); //oldPoint2.x *=-1; Vector3 newPoint2 = Handles.FreeMoveHandle( oldPoint2, Quaternion.identity, size * 0.05f, pointSnap, Handles.DotCap); if (oldPoint2 != newPoint2) { Undo.RecordObject(light, "resize radiusLight"); light.LightRadius = (lTransform.InverseTransformPoint(newPoint2).magnitude); light.Rebuild(); } Handles.color = Color.yellow; Handles.DrawWireDisc(lTransform.position, new Vector3(0, 0, -1), light.LightRadius); if (light.RangeAngle < 360) { Handles.DrawLine(lTransform.position, lTransform.TransformPoint(light.getMaxFromAllVerts())); Handles.DrawLine(lTransform.position, lTransform.TransformPoint(light.getMinFromAllVerts())); } dragAndDropEvents(); } }
void OnSceneGUI() { if (light) { Transform lTransform = light.transform; Vector3 oldPoint = lTransform.TransformPoint(new Vector3(light.LightRadius, 0, 0)); float size = HandleUtility.GetHandleSize(oldPoint); Undo.RecordObject(light, "Move Light Radius Point"); Vector3 newPoint = Handles.FreeMoveHandle( oldPoint, Quaternion.identity, size * 0.05f, pointSnap, Handles.DotCap); if (oldPoint != newPoint) { Undo.RecordObject(light, "resize radiusLight"); light.LightRadius = (lTransform.InverseTransformPoint(newPoint).magnitude); light.Rebuild(); } Vector3 oldPoint2 = lTransform.TransformPoint(new Vector3(-light.LightRadius, 0, 0)); //oldPoint2.x *=-1; Vector3 newPoint2 = Handles.FreeMoveHandle( oldPoint2, Quaternion.identity, size * 0.05f, pointSnap, Handles.DotCap); if (oldPoint2 != newPoint2) { Undo.RecordObject(light, "resize radiusLight"); light.LightRadius = (lTransform.InverseTransformPoint(newPoint2).magnitude); light.Rebuild(); } Handles.color = Color.yellow; Handles.DrawWireDisc(lTransform.position, new Vector3(0, 0, -1), light.LightRadius); if (light.RangeAngle < 360) { Handles.DrawLine(lTransform.position, lTransform.TransformPoint(light.getMaxFromAllVerts())); Handles.DrawLine(lTransform.position, lTransform.TransformPoint(light.getMinFromAllVerts())); } /* Angle Handler*/ Handles.color = Color.grey; Vector3 oldAnglePoint = lTransform.TransformPoint(new Vector3(0, -((light.RangeAngle * light.LightRadius) / 360), 0)); //float sizeAngle = HandleUtility.GetHandleSize(oldAnglePoint); Vector3 newAngPoint = Handles.FreeMoveHandle( oldAnglePoint, Quaternion.identity, size * 0.08f, pointAngleSnap, Handles.DotCap); Handles.DrawLine(lTransform.position, newAngPoint); if (oldAnglePoint != newAngPoint) { Undo.RecordObject(light, "resize range angle"); newAngPoint = lTransform.InverseTransformPoint(newAngPoint); oldAnglePoint = lTransform.InverseTransformPoint(oldAnglePoint); float _tmpAng = (newAngPoint - oldAnglePoint).y; light.RangeAngle -= _tmpAng; if (light.RangeAngle > 360f) { light.RangeAngle = 360f; } if (light.RangeAngle < 1f) { light.RangeAngle = 1f; } light.Rebuild(); } /* end angle handler */ dragAndDropEvents(); } }