static private ConeHandle ( |
||
rotation | ||
position | Vector3 | |
angleAndRange | Vector2 | |
angleScale | float | |
rangeScale | float | |
handlesOnly | bool | |
Результат | Vector2 |
private void OnSceneGUI() { Light light = (Light)this.target; Color color = Handles.color; if (light.enabled) { Handles.color = LightEditor.kGizmoLight; } else { Handles.color = LightEditor.kGizmoDisabledLight; } float num = light.range; switch (light.type) { case LightType.Spot: { Color color2 = Handles.color; color2.a = Mathf.Clamp01(color.a * 2f); Handles.color = color2; Vector2 angleAndRange = new Vector2(light.spotAngle, light.range); angleAndRange = Handles.ConeHandle(light.transform.rotation, light.transform.position, angleAndRange, 1f, 1f, true); if (GUI.changed) { Undo.RecordObject(light, "Adjust Spot Light"); light.spotAngle = angleAndRange.x; light.range = Mathf.Max(angleAndRange.y, 0.01f); } break; } case LightType.Point: num = Handles.RadiusHandle(Quaternion.identity, light.transform.position, num, true); if (GUI.changed) { Undo.RecordObject(light, "Adjust Point Light"); light.range = num; } break; case LightType.Area: { EditorGUI.BeginChangeCheck(); Vector2 areaSize = Handles.DoRectHandles(light.transform.rotation, light.transform.position, light.areaSize); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(light, "Adjust Area Light"); light.areaSize = areaSize; } break; } } Handles.color = color; }
private void OnSceneGUI() { Light target = (Light)this.target; Color color1 = Handles.color; Handles.color = !target.enabled ? LightEditor.kGizmoDisabledLight : LightEditor.kGizmoLight; float range = target.range; switch (target.type) { case LightType.Spot: Color color2 = Handles.color; color2.a = Mathf.Clamp01(color1.a * 2f); Handles.color = color2; Vector2 angleAndRange = new Vector2(target.spotAngle, target.range); angleAndRange = Handles.ConeHandle(target.transform.rotation, target.transform.position, angleAndRange, 1f, 1f, true); if (GUI.changed) { Undo.RecordObject((Object)target, "Adjust Spot Light"); target.spotAngle = angleAndRange.x; target.range = Mathf.Max(angleAndRange.y, 0.01f); break; } break; case LightType.Point: float num = Handles.RadiusHandle(Quaternion.identity, target.transform.position, range, true); if (GUI.changed) { Undo.RecordObject((Object)target, "Adjust Point Light"); target.range = num; break; } break; case LightType.Area: EditorGUI.BeginChangeCheck(); Vector2 vector2 = Handles.DoRectHandles(target.transform.rotation, target.transform.position, target.areaSize); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject((Object)target, "Adjust Area Light"); target.areaSize = vector2; break; } break; } Handles.color = color1; }
protected virtual void OnSceneGUI() { Light t = target as Light; Color temp = Handles.color; if (t.enabled) { Handles.color = kGizmoLight; } else { Handles.color = kGizmoDisabledLight; } float thisRange = t.range; switch (t.type) { case LightType.Point: thisRange = Handles.RadiusHandle(Quaternion.identity, t.transform.position, thisRange, true); if (GUI.changed) { Undo.RecordObject(t, "Adjust Point Light"); t.range = thisRange; } break; case LightType.Spot: // Give handles twice the alpha of the lines Color col = Handles.color; col.a = Mathf.Clamp01(temp.a * 2); Handles.color = col; Vector2 angleAndRange = new Vector2(t.spotAngle, t.range); angleAndRange = Handles.ConeHandle(t.transform.rotation, t.transform.position, angleAndRange, 1.0f, 1.0f, true); if (GUI.changed) { Undo.RecordObject(t, "Adjust Spot Light"); t.spotAngle = angleAndRange.x; t.range = Mathf.Max(angleAndRange.y, 0.01F); } break; case LightType.Area: EditorGUI.BeginChangeCheck(); Vector2 size = Handles.DoRectHandles(t.transform.rotation, t.transform.position, t.areaSize); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(t, "Adjust Area Light"); t.areaSize = size; } break; default: break; } Handles.color = temp; }
protected virtual void OnSceneGUI() { Light t = target as Light; Color temp = Handles.color; if (t.enabled) { Handles.color = kGizmoLight; } else { Handles.color = kGizmoDisabledLight; } float thisRange = t.range; switch (t.type) { case LightType.Directional: Vector3 lightPos = t.transform.position; float lightSize; using (new Handles.DrawingScope(Matrix4x4.identity)) //be sure no matrix affect the size computation { lightSize = HandleUtility.GetHandleSize(lightPos); } float radius = lightSize * 0.2f; using (new Handles.DrawingScope(Matrix4x4.TRS(lightPos, t.transform.rotation, Vector3.one))) { Handles.DrawWireDisc(Vector3.zero, Vector3.forward, radius); foreach (Vector3 normalizedPos in directionalLightHandlesRayPositions) { Vector3 pos = normalizedPos * radius; Handles.DrawLine(pos, pos + new Vector3(0, 0, lightSize)); } } break; case LightType.Point: thisRange = Handles.RadiusHandle(Quaternion.identity, t.transform.position, thisRange); if (GUI.changed) { Undo.RecordObject(t, "Adjust Point Light"); t.range = thisRange; } break; case LightType.Spot: Transform tr = t.transform; Vector3 circleCenter = tr.position; Vector3 arrivalCenter = circleCenter + tr.forward * t.range; float lightDisc = t.range * Mathf.Tan(Mathf.Deg2Rad * t.spotAngle / 2.0f); Handles.DrawLine(circleCenter, arrivalCenter + tr.up * lightDisc); Handles.DrawLine(circleCenter, arrivalCenter - tr.up * lightDisc); Handles.DrawLine(circleCenter, arrivalCenter + tr.right * lightDisc); Handles.DrawLine(circleCenter, arrivalCenter - tr.right * lightDisc); Handles.DrawWireDisc(arrivalCenter, tr.forward, lightDisc); Handles.color = GetLightHandleColor(Handles.color); Vector2 angleAndRange = new Vector2(t.spotAngle, t.range); angleAndRange = Handles.ConeHandle(t.transform.rotation, t.transform.position, angleAndRange, 1.0f, 1.0f, true); if (GUI.changed) { Undo.RecordObject(t, "Adjust Spot Light"); t.spotAngle = angleAndRange.x; t.range = Mathf.Max(angleAndRange.y, 0.01F); } break; case LightType.Rectangle: EditorGUI.BeginChangeCheck(); Vector2 size = Handles.DoRectHandles(t.transform.rotation, t.transform.position, t.areaSize, false); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(t, "Adjust Rect Light"); t.areaSize = size; } // Draw the area light's normal only if it will not overlap with the current tool if (!((Tools.current == Tool.Move || Tools.current == Tool.Scale) && Tools.pivotRotation == PivotRotation.Local)) { Handles.DrawLine(t.transform.position, t.transform.position + t.transform.forward); } break; case LightType.Disc: m_BoundsHandle.radius = t.areaSize.x; m_BoundsHandle.axes = IMGUI.Controls.PrimitiveBoundsHandle.Axes.X | IMGUI.Controls.PrimitiveBoundsHandle.Axes.Y; m_BoundsHandle.center = Vector3.zero; m_BoundsHandle.wireframeColor = Handles.color; m_BoundsHandle.handleColor = GetLightHandleColor(Handles.color); Matrix4x4 mat = new Matrix4x4(); mat.SetTRS(t.transform.position, t.transform.rotation, new Vector3(1, 1, 1)); EditorGUI.BeginChangeCheck(); using (new Handles.DrawingScope(Color.white, mat)) m_BoundsHandle.DrawHandle(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(t, "Adjust Disc Light"); t.areaSize = new Vector2(m_BoundsHandle.radius, t.areaSize.y); } break; } Handles.color = temp; }