private CurveWrapper CreateCurveWrapper(SerializedProperty curve, int id, int regionId, Color color, bool signedRange, CurveWrapper.GetAxisScalarsCallback getAxisScalarsCallback, CurveWrapper.SetAxisScalarsCallback setAxisScalarsCallback) { float end = 1f; CurveWrapper wrapper = new CurveWrapper { id = id, regionId = regionId, color = color, renderer = new NormalCurveRenderer(curve.animationCurveValue) }; wrapper.renderer.SetCustomRange(0f, end); wrapper.vRangeMin = !signedRange ? 0f : -1f; wrapper.getAxisUiScalarsCallback = getAxisScalarsCallback; wrapper.setAxisUiScalarsCallback = setAxisScalarsCallback; return wrapper; }
private CurveWrapper GetCurveWrapper(AnimationCurve curve) { float r = EditorGUIUtility.isProSkin ? 1f : 0.9f; Color color = new Color(r, r, r, 1f); CurveWrapper wrapper = new CurveWrapper { id = 0, groupId = -1, color = new Color(1f, 0f, 0f, 1f) * color, hidden = false, readOnly = false, renderer = new NormalCurveRenderer(curve) }; wrapper.renderer.SetCustomRange(0f, 1f); wrapper.getAxisUiScalarsCallback = new CurveWrapper.GetAxisScalarsCallback(this.GetAxisScalars); return wrapper; }
private CurveWrapper[] GetCurveWrapperArray() { if (this.m_Curve == null) { return new CurveWrapper[0]; } CurveWrapper wrapper = new CurveWrapper { id = "Curve".GetHashCode(), groupId = -1, color = this.m_Color, hidden = false, readOnly = false, renderer = new NormalCurveRenderer(this.m_Curve) }; wrapper.renderer.SetWrap(this.m_Curve.preWrapMode, this.m_Curve.postWrapMode); return new CurveWrapper[] { wrapper }; }
private CurveWrapper CreateCurveWrapper(SerializedProperty curve, int id, int regionId, Color color, bool signedRange, CurveWrapper.GetAxisScalarsCallback getAxisScalarsCallback, CurveWrapper.SetAxisScalarsCallback setAxisScalarsCallback) { CurveWrapper wrapper = new CurveWrapper { id = id, regionId = regionId, color = color, renderer = new NormalCurveRenderer(curve.animationCurveValue) }; wrapper.renderer.SetWrap(curve.animationCurveValue.preWrapMode, curve.animationCurveValue.postWrapMode); if (wrapper.curve.keys.Length == 1) { wrapper.renderer.SetCustomRange(0f, 1f); wrapper.wrapColorMultiplier = Color.clear; } else { wrapper.renderer.SetCustomRange(0f, 0f); wrapper.wrapColorMultiplier = color; } wrapper.vRangeMin = !signedRange ? 0f : -1f; wrapper.getAxisUiScalarsCallback = getAxisScalarsCallback; wrapper.setAxisUiScalarsCallback = setAxisScalarsCallback; return wrapper; }
public void RefreshCurves() { if (this.m_ClipDataSource != null && this.m_Selection != null) { List <EditorCurveBinding> list = new List <EditorCurveBinding>(); int[] selection = this.m_Selection; for (int i = 0; i < selection.Length; i++) { int num = selection[i]; CurveTreeViewNode curveTreeViewNode = (CurveTreeViewNode)this.m_TreeView.FindItem(num); if (curveTreeViewNode != null && curveTreeViewNode.bindings != null) { list.AddRange(curveTreeViewNode.bindings); } } AnimationClip animationClip = this.m_ClipDataSource.animationClip; List <CurveWrapper> list2 = new List <CurveWrapper>(); int num2 = 0; foreach (EditorCurveBinding current in list) { CurveWrapper curveWrapper = new CurveWrapper(); curveWrapper.id = num2++; curveWrapper.binding = current; curveWrapper.groupId = -1; curveWrapper.color = CurveUtility.GetPropertyColor(current.propertyName); curveWrapper.hidden = false; curveWrapper.readOnly = false; curveWrapper.set_renderer(new NormalCurveRenderer(AnimationUtility.GetEditorCurve(animationClip, current))); curveWrapper.getAxisUiScalarsCallback = new CurveWrapper.GetAxisScalarsCallback(this.GetAxisScalars); CurveWrapper curveWrapper2 = curveWrapper; curveWrapper2.get_renderer().SetCustomRange(0f, animationClip.get_length()); list2.Add(curveWrapper2); } this.m_CurveEditor.set_animationCurves(list2.ToArray()); } }
public CurveData(string name, GUIContent displayName, SerializedProperty min, SerializedProperty max, Color color, bool signedRange, CurveWrapper.GetAxisScalarsCallback getAxisScalars, CurveWrapper.SetAxisScalarsCallback setAxisScalars, bool visible) { this.m_UniqueName = name; this.m_DisplayName = displayName; this.m_SignedRange = signedRange; this.m_Min = min; this.m_Max = max; if (this.m_Min != null) { this.m_MinId = ++ParticleSystemCurveEditor.CurveData.s_IdCounter; } if (this.m_Max != null) { this.m_MaxId = ++ParticleSystemCurveEditor.CurveData.s_IdCounter; } this.m_Color = color; this.m_GetAxisScalarsCallback = getAxisScalars; this.m_SetAxisScalarsCallback = setAxisScalars; this.m_Visible = visible; if (this.m_Max == null || this.m_MaxId == 0) { Debug.LogError("Max curve should always be valid! (Min curve can be null)"); } }
CurveWrapper[] GetCurveWrapperArray() { if (m_Curve == null) { return new CurveWrapper[] {} } ; CurveWrapper cw = new CurveWrapper(); cw.id = "Curve".GetHashCode(); cw.groupId = -1; cw.color = m_Color; cw.hidden = false; cw.readOnly = false; cw.renderer = new NormalCurveRenderer(m_Curve); cw.renderer.SetWrap(m_Curve.preWrapMode, m_Curve.postWrapMode); return(new CurveWrapper[] { cw }); } Rect GetCurveEditorRect() { //return new Rect(0, kToolbarHeight, position.width, position.height-kToolbarHeight); return(new Rect(0, 0, position.width, position.height - kPresetsHeight)); }
private CurveWrapper[] GetCurveWrapperArray() { CurveWrapper[] result; if (this.m_Curve == null) { result = new CurveWrapper[0]; } else { CurveWrapper curveWrapper = new CurveWrapper(); curveWrapper.id = "Curve".GetHashCode(); curveWrapper.groupId = -1; curveWrapper.color = this.m_Color; curveWrapper.hidden = false; curveWrapper.readOnly = false; curveWrapper.renderer = new NormalCurveRenderer(this.m_Curve); curveWrapper.renderer.SetWrap(this.m_Curve.preWrapMode, this.m_Curve.postWrapMode); result = new CurveWrapper[] { curveWrapper }; } return(result); }
private void DrawCurve(CurveWrapper cw, bool hasFocus) { CurveRenderer renderer = cw.renderer; Color color = cw.color; if (this.IsDraggingCurve(cw) || cw.selected == CurveWrapper.SelectionMode.Selected) { color = Color.Lerp(color, Color.white, 0.3f); } else { if (base.settings.useFocusColors && !hasFocus) { color *= 0.5f; color.a = 0.8f; } } Rect shownArea = base.shownArea; renderer.DrawCurve(shownArea.xMin, shownArea.xMax, color, base.drawingToViewMatrix, base.settings.wrapColor); }
public void DrawRegion(CurveWrapper curve1, CurveWrapper curve2, bool hasFocus) { float deltaTime = 1f / (base.rect.width / 10f); List<Vector3> list = CurveEditor.CreateRegion(curve1, curve2, deltaTime); Color color = curve1.color; for (int i = 0; i < list.Count; i++) { list[i] = base.drawingToViewMatrix.MultiplyPoint(list[i]); } if (this.IsDraggingRegion(curve1, curve2)) { color = Color.Lerp(color, Color.black, 0.1f); color.a = 0.4f; } else { if (base.settings.useFocusColors && !hasFocus) { color *= 0.4f; color.a = 0.1f; } else { color *= 1f; color.a = 0.4f; } } Shader.SetGlobalColor("_HandleColor", color); HandleUtility.ApplyWireMaterial(); GL.Begin(4); int num = list.Count / 3; for (int j = 0; j < num; j++) { GL.Color(color); GL.Vertex(list[j * 3]); GL.Vertex(list[j * 3 + 1]); GL.Vertex(list[j * 3 + 2]); } GL.End(); }
private static List<Vector3> CreateRegion(CurveWrapper minCurve, CurveWrapper maxCurve, float deltaTime) { List<Vector3> list = new List<Vector3>(); List<float> list2 = new List<float>(); float num; for (num = deltaTime; num <= 1f; num += deltaTime) { list2.Add(num); } if (num != 1f) { list2.Add(1f); } Keyframe[] keys = maxCurve.curve.keys; for (int i = 0; i < keys.Length; i++) { Keyframe keyframe = keys[i]; if (keyframe.time > 0f && keyframe.time < 1f) { list2.Add(keyframe.time - 0.0001f); list2.Add(keyframe.time); list2.Add(keyframe.time + 0.0001f); } } Keyframe[] keys2 = minCurve.curve.keys; for (int j = 0; j < keys2.Length; j++) { Keyframe keyframe2 = keys2[j]; if (keyframe2.time > 0f && keyframe2.time < 1f) { list2.Add(keyframe2.time - 0.0001f); list2.Add(keyframe2.time); list2.Add(keyframe2.time + 0.0001f); } } list2.Sort(); Vector3 vector = new Vector3(0f, maxCurve.renderer.EvaluateCurveSlow(0f), 0f); Vector3 vector2 = new Vector3(0f, minCurve.renderer.EvaluateCurveSlow(0f), 0f); for (int k = 0; k < list2.Count; k++) { float num2 = list2[k]; Vector3 vector3 = new Vector3(num2, maxCurve.renderer.EvaluateCurveSlow(num2), 0f); Vector3 vector4 = new Vector3(num2, minCurve.renderer.EvaluateCurveSlow(num2), 0f); if (vector.y >= vector2.y && vector3.y >= vector4.y) { list.Add(vector); list.Add(vector4); list.Add(vector2); list.Add(vector); list.Add(vector3); list.Add(vector4); } else { if (vector.y <= vector2.y && vector3.y <= vector4.y) { list.Add(vector2); list.Add(vector3); list.Add(vector); list.Add(vector2); list.Add(vector4); list.Add(vector3); } else { Vector2 zero = Vector2.zero; if (Mathf.LineIntersection(vector, vector3, vector2, vector4, ref zero)) { list.Add(vector); list.Add(zero); list.Add(vector2); list.Add(vector3); list.Add(zero); list.Add(vector4); } else { Debug.Log("Error: No intersection found! There should be one..."); } } } vector = vector3; vector2 = vector4; } return list; }
private bool HandleCurveAndRegionMoveToFrontOnMouseDown(ref Vector2 timeValue, ref CurveWrapper[] curves) { Vector2 vector; int curveAtPosition = this.GetCurveAtPosition(base.mousePositionInDrawing, out vector); if (curveAtPosition >= 0) { this.MoveCurveToFront(this.m_AnimationCurves[curveAtPosition].id); timeValue = base.mousePositionInDrawing; curves = new CurveWrapper[] { this.m_AnimationCurves[curveAtPosition] }; return true; } for (int i = this.m_DrawOrder.Count - 1; i >= 0; i--) { CurveWrapper curveWrapperById = this.getCurveWrapperById(this.m_DrawOrder[i]); if (curveWrapperById != null) { if (!curveWrapperById.hidden) { if (curveWrapperById.curve.length != 0) { CurveWrapper curveWrapper = null; if (i > 0) { curveWrapper = this.getCurveWrapperById(this.m_DrawOrder[i - 1]); } if (this.IsRegion(curveWrapperById, curveWrapper)) { float y = base.mousePositionInDrawing.y; float x = base.mousePositionInDrawing.x; float num = curveWrapperById.renderer.EvaluateCurveSlow(x); float num2 = curveWrapper.renderer.EvaluateCurveSlow(x); if (num > num2) { float num3 = num; num = num2; num2 = num3; } if (y >= num && y <= num2) { timeValue = base.mousePositionInDrawing; curves = new CurveWrapper[] { curveWrapperById, curveWrapper }; this.MoveCurveToFront(curveWrapperById.id); return true; } i--; } } } } } return false; }
public void RefreshShownCurves(bool forceUpdate) { this.state.m_CurveEditorIsDirty = false; if (!this.SelectionIsActive()) { this.ClearShownProperties(); return; } if (this.state.m_ShowCurveEditor || forceUpdate) { this.SetupEditorCurvesHack(); } else { this.ClearShownProperties(); } this.EvaluateFramerate(); this.m_CurveEditor.invSnap = this.state.frameRate; bool flag = this.AnyPropertiesSelected(); CurveWrapper[] array = new CurveWrapper[this.m_EditedCurves.Length]; for (int i = 0; i < array.Length; i++) { CurveState curveState = this.m_ShownProperties[this.m_EditedCurves[i]]; array[i] = new CurveWrapper(); array[i].id = curveState.GetID(); if (this.IsLinked(curveState, true)) { array[i].groupId = curveState.GetGroupID(); } else { array[i].groupId = -1; } array[i].color = curveState.color; array[i].hidden = (flag && !this.m_SelectedProperties[this.m_EditedCurves[i]]); if (array[i].readOnly) { array[i].color.a = 0.3f; } array[i].renderer = CurveRendererCache.GetCurveRenderer(curveState.clip, curveState.curveBinding); array[i].renderer.SetWrap((!curveState.clip.isLooping) ? WrapMode.Once : WrapMode.Loop); array[i].renderer.SetCustomRange(0f, curveState.clip.length); } this.m_CurveEditor.animationCurves = array; if (AnimationMode.InAnimationMode() && GUI.changed) { this.ResampleAnimation(); } }
public override void OnInspectorGUI() { AudioSourceInspector.InitStyles(); base.serializedObject.Update(); if (this.m_LowpassObject != null) { this.m_LowpassObject.Update(); } this.HandleLowPassFilter(); AudioSourceInspector.AudioCurveWrapper[] audioCurves = this.m_AudioCurves; for (int i = 0; i < audioCurves.Length; i++) { AudioSourceInspector.AudioCurveWrapper audioCurveWrapper = audioCurves[i]; CurveWrapper curveWrapperFromID = this.m_CurveEditor.GetCurveWrapperFromID(audioCurveWrapper.id); if (audioCurveWrapper.curveProp != null) { AnimationCurve animationCurveValue = audioCurveWrapper.curveProp.animationCurveValue; if (curveWrapperFromID == null != audioCurveWrapper.curveProp.hasMultipleDifferentValues) { this.m_RefreshCurveEditor = true; } else if (curveWrapperFromID != null) { if (curveWrapperFromID.curve.length == 0) { this.m_RefreshCurveEditor = true; } else if (animationCurveValue.length >= 1 && animationCurveValue.keys[0].value != curveWrapperFromID.curve.keys[0].value) { this.m_RefreshCurveEditor = true; } } } else if (curveWrapperFromID != null) { this.m_RefreshCurveEditor = true; } } this.UpdateWrappersAndLegend(); EditorGUILayout.PropertyField(this.m_AudioClip, AudioSourceInspector.ms_Styles.audioClipLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.PropertyField(this.m_OutputAudioMixerGroup, AudioSourceInspector.ms_Styles.outputMixerGroupLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Mute, new GUILayoutOption[0]); if (AudioUtil.canUseSpatializerEffect) { EditorGUILayout.PropertyField(this.m_Spatialize, AudioSourceInspector.ms_Styles.spatializeLabel, new GUILayoutOption[0]); using (new EditorGUI.DisabledScope(!this.m_Spatialize.boolValue)) { EditorGUILayout.PropertyField(this.m_SpatializePostEffects, AudioSourceInspector.ms_Styles.spatializePostEffectsLabel, new GUILayoutOption[0]); } } EditorGUILayout.PropertyField(this.m_BypassEffects, new GUILayoutOption[0]); if (base.targets.Any((UnityEngine.Object t) => (t as AudioSource).outputAudioMixerGroup != null)) { using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.PropertyField(this.m_BypassListenerEffects, new GUILayoutOption[0]); } } else { EditorGUILayout.PropertyField(this.m_BypassListenerEffects, new GUILayoutOption[0]); } EditorGUILayout.PropertyField(this.m_BypassReverbZones, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_PlayOnAwake, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Loop, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.priorityLeftLabel, AudioSourceInspector.ms_Styles.priorityRightLabel); EditorGUILayout.IntSlider(this.m_Priority, 0, 256, AudioSourceInspector.ms_Styles.priorityLabel, new GUILayoutOption[0]); EditorGUIUtility.sliderLabels.SetLabels(null, null); EditorGUILayout.Space(); EditorGUILayout.Slider(this.m_Volume, 0f, 1f, AudioSourceInspector.ms_Styles.volumeLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.Slider(this.m_Pitch, -3f, 3f, AudioSourceInspector.ms_Styles.pitchLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.panLeftLabel, AudioSourceInspector.ms_Styles.panRightLabel); EditorGUILayout.Slider(this.m_Pan2D, -1f, 1f, AudioSourceInspector.ms_Styles.panStereoLabel, new GUILayoutOption[0]); EditorGUIUtility.sliderLabels.SetLabels(null, null); EditorGUILayout.Space(); EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.spatialLeftLabel, AudioSourceInspector.ms_Styles.spatialRightLabel); AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.spatialBlendLabel, this.m_AudioCurves[1].curveProp, 0f, 1f, false); EditorGUIUtility.sliderLabels.SetLabels(null, null); EditorGUILayout.Space(); AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.reverbZoneMixLabel, this.m_AudioCurves[4].curveProp, 0f, 1.1f, false); EditorGUILayout.Space(); this.m_Expanded3D = EditorGUILayout.Foldout(this.m_Expanded3D, "3D Sound Settings", true); if (this.m_Expanded3D) { EditorGUI.indentLevel++; this.Audio3DGUI(); EditorGUI.indentLevel--; } base.serializedObject.ApplyModifiedProperties(); if (this.m_LowpassObject != null) { this.m_LowpassObject.ApplyModifiedProperties(); } }
public override void OnInspectorGUI() { AudioSourceInspector.InitStyles(); this.serializedObject.Update(); if (this.m_LowpassObject != null) { this.m_LowpassObject.Update(); } this.HandleLowPassFilter(); foreach (AudioSourceInspector.AudioCurveWrapper audioCurve in this.m_AudioCurves) { CurveWrapper curveWrapperById = this.m_CurveEditor.getCurveWrapperById(audioCurve.id); if (audioCurve.curveProp != null) { AnimationCurve animationCurveValue = audioCurve.curveProp.animationCurveValue; if (curveWrapperById == null != audioCurve.curveProp.hasMultipleDifferentValues) { this.m_RefreshCurveEditor = true; } else if (curveWrapperById != null) { if (curveWrapperById.curve.length == 0) { this.m_RefreshCurveEditor = true; } else if (animationCurveValue.length >= 1 && (double)animationCurveValue.keys[0].value != (double)curveWrapperById.curve.keys[0].value) { this.m_RefreshCurveEditor = true; } } } else if (curveWrapperById != null) { this.m_RefreshCurveEditor = true; } } this.UpdateWrappersAndLegend(); EditorGUILayout.PropertyField(this.m_AudioClip, AudioSourceInspector.ms_Styles.audioClipLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.PropertyField(this.m_OutputAudioMixerGroup, AudioSourceInspector.ms_Styles.outputMixerGroupLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Mute); if (AudioUtil.canUseSpatializerEffect) { EditorGUILayout.PropertyField(this.m_Spatialize); } EditorGUILayout.PropertyField(this.m_BypassEffects); bool flag = ((IEnumerable <UnityEngine.Object>) this.targets).Any <UnityEngine.Object>((Func <UnityEngine.Object, bool>)(t => (UnityEngine.Object)(t as AudioSource).outputAudioMixerGroup != (UnityEngine.Object)null)); if (flag) { EditorGUI.BeginDisabledGroup(true); } EditorGUILayout.PropertyField(this.m_BypassListenerEffects); if (flag) { EditorGUI.EndDisabledGroup(); } EditorGUILayout.PropertyField(this.m_BypassReverbZones); EditorGUILayout.PropertyField(this.m_PlayOnAwake); EditorGUILayout.PropertyField(this.m_Loop); EditorGUILayout.Space(); EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.priorityLeftLabel, AudioSourceInspector.ms_Styles.priorityRightLabel); EditorGUILayout.IntSlider(this.m_Priority, 0, 256, AudioSourceInspector.ms_Styles.priorityLabel, new GUILayoutOption[0]); EditorGUIUtility.sliderLabels.SetLabels((GUIContent)null, (GUIContent)null); EditorGUILayout.Space(); EditorGUILayout.Slider(this.m_Volume, 0.0f, 1f, AudioSourceInspector.ms_Styles.volumeLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.Slider(this.m_Pitch, -3f, 3f, AudioSourceInspector.ms_Styles.pitchLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.panLeftLabel, AudioSourceInspector.ms_Styles.panRightLabel); EditorGUILayout.Slider(this.m_Pan2D, -1f, 1f, AudioSourceInspector.ms_Styles.panStereoLabel, new GUILayoutOption[0]); EditorGUIUtility.sliderLabels.SetLabels((GUIContent)null, (GUIContent)null); EditorGUILayout.Space(); EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.spatialLeftLabel, AudioSourceInspector.ms_Styles.spatialRightLabel); AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.spatialBlendLabel, this.m_AudioCurves[1].curveProp, 0.0f, 1f, false); EditorGUIUtility.sliderLabels.SetLabels((GUIContent)null, (GUIContent)null); EditorGUILayout.Space(); AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.reverbZoneMixLabel, this.m_AudioCurves[4].curveProp, 0.0f, 1.1f, false); EditorGUILayout.Space(); this.m_Expanded3D = EditorGUILayout.Foldout(this.m_Expanded3D, "3D Sound Settings"); if (this.m_Expanded3D) { ++EditorGUI.indentLevel; this.Audio3DGUI(); --EditorGUI.indentLevel; } this.serializedObject.ApplyModifiedProperties(); if (this.m_LowpassObject == null) { return; } this.m_LowpassObject.ApplyModifiedProperties(); }
private bool IsRegion(CurveWrapper cw1, CurveWrapper cw2) { return cw1 != null && cw2 != null && cw1.regionId >= 0 && cw1.regionId == cw2.regionId; }
private bool IsRegionCurveSelected(CurveWrapper cw1, CurveWrapper cw2) { return this.IsCurveSelected(cw1) || this.IsCurveSelected(cw2); }
private bool IsCurveSelected(CurveWrapper cw) { return cw != null && cw.selected != CurveWrapper.SelectionMode.None; }
private void ResetDragging() { if (this.m_DraggingCurveOrRegion != null) { this.SelectNone(); } GUIUtility.hotControl = 0; this.m_DraggingKey = null; this.m_DraggingCurveOrRegion = null; this.m_DisplayedSelection = null; this.m_MoveCoord = Vector2.zero; }
public CurveEditor(Rect rect, CurveWrapper[] curves, bool minimalGUI) : base(minimalGUI) { base.rect = rect; this.animationCurves = curves; float[] tickModulos = new float[] { 1E-07f, 5E-07f, 1E-06f, 5E-06f, 1E-05f, 5E-05f, 0.0001f, 0.0005f, 0.001f, 0.005f, 0.01f, 0.05f, 0.1f, 0.5f, 1f, 5f, 10f, 50f, 100f, 500f, 1000f, 5000f, 10000f, 50000f, 100000f, 500000f, 1000000f, 5000000f, 1E+07f }; base.hTicks = new TickHandler(); base.hTicks.SetTickModulos(tickModulos); base.vTicks = new TickHandler(); base.vTicks.SetTickModulos(tickModulos); base.margin = 40f; Undo.undoRedoPerformed = (Undo.UndoRedoCallback)Delegate.Combine(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.UndoRedoPerformed)); }
private void SetupKeyOrCurveDragging(Vector2 timeValue, CurveWrapper cw, int id, Vector2 mousePos) { this.m_DraggedCoord = timeValue; this.m_DraggingKey = cw; GUIUtility.hotControl = id; this.MakeCurveBackups(); this.s_StartMouseDragPosition = mousePos; this.activeTime = timeValue.x; this.s_StartClickedTime = timeValue.x; }
public SavedKeyFrame(Keyframe key, CurveWrapper.SelectionMode selected) { this.key = key; this.selected = selected; }
private void DrawPointsOnCurve(CurveWrapper cw, List<CurveSelection> selected, bool hasFocus) { this.m_PreviousDrawPointCenter = new Vector2(-3.40282347E+38f, -3.40282347E+38f); if (selected == null) { Color color = cw.color; if (base.settings.useFocusColors && !hasFocus) { color *= 0.5f; } GUI.color = color; Keyframe[] keys = cw.curve.keys; for (int i = 0; i < keys.Length; i++) { Keyframe keyframe = keys[i]; this.DrawPoint(keyframe.time, keyframe.value, this.ms_Styles.pointIcon); } } else { Color color2 = Color.Lerp(cw.color, Color.white, 0.2f); GUI.color = color2; int num = 0; while (num < selected.Count && selected[num].curveID != cw.id) { num++; } int num2 = 0; Keyframe[] keys2 = cw.curve.keys; for (int j = 0; j < keys2.Length; j++) { Keyframe keyframe2 = keys2[j]; if (num < selected.Count && selected[num].key == num2 && selected[num].curveID == cw.id) { Vector3 vector = base.DrawingToViewTransformPoint(new Vector3(keyframe2.time, keyframe2.value, 0f)); vector = new Vector3(Mathf.Floor(vector.x), Mathf.Floor(vector.y), 0f); Rect position = new Rect(vector.x - 4f, vector.y - 4f, (float)this.ms_Styles.pointIcon.width, (float)this.ms_Styles.pointIcon.height); GUI.Label(position, this.ms_Styles.pointIconSelected, this.ms_Styles.none); GUI.color = Color.white; if (!selected[num].semiSelected) { GUI.Label(position, this.ms_Styles.pointIconSelectedOverlay, this.ms_Styles.none); } else { GUI.Label(position, this.ms_Styles.pointIconSemiSelectedOverlay, this.ms_Styles.none); } GUI.color = color2; num++; } else { this.DrawPoint(keyframe2.time, keyframe2.value, this.ms_Styles.pointIcon); } num2++; } GUI.color = Color.white; } }
private CurveWrapper[] GetCurveWrapperArray() { if (this.m_Curve == null) { return new CurveWrapper[0]; } CurveWrapper curveWrapper = new CurveWrapper(); curveWrapper.id = "Curve".GetHashCode(); curveWrapper.groupId = -1; curveWrapper.color = this.m_Color; curveWrapper.hidden = false; curveWrapper.readOnly = false; curveWrapper.renderer = new NormalCurveRenderer(this.m_Curve); curveWrapper.renderer.SetWrap(this.m_Curve.preWrapMode, this.m_Curve.postWrapMode); return new CurveWrapper[] { curveWrapper }; }
private void SaveCurve(SerializedProperty prop, CurveWrapper cw) { if (cw.curve.keys.Length == 1) { cw.renderer.SetCustomRange(0f, 1f); cw.wrapColorMultiplier = Color.clear; } else { cw.renderer.SetCustomRange(0f, 0f); cw.wrapColorMultiplier = cw.color; } prop.animationCurveValue = cw.curve; cw.changed = false; }
public static CurveWrapper GetCurveWrapper(AnimationWindowCurve curve, AnimationClip clip) { CurveWrapper curveWrapper = new CurveWrapper(); curveWrapper.renderer = (CurveRenderer) new NormalCurveRenderer(curve.ToAnimationCurve()); curveWrapper.renderer.SetWrap(WrapMode.Once, !clip.isLooping ? WrapMode.Once : WrapMode.Loop); curveWrapper.renderer.SetCustomRange(clip.startTime, clip.stopTime); curveWrapper.binding = curve.binding; curveWrapper.id = CurveUtility.GetCurveID(clip, curve.binding); curveWrapper.color = CurveUtility.GetPropertyColor(curve.propertyName); curveWrapper.hidden = false; return curveWrapper; }
private void SetCurve(CurveWrapper cw, AnimationCurve curve) { Keyframe[] destinationArray = new Keyframe[curve.keys.Length]; Array.Copy(curve.keys, destinationArray, destinationArray.Length); cw.curve.keys = destinationArray; cw.changed = true; }
public void DrawCurveEditor(Rect animEditorRect, TimelineWindow.TimelineState state, Vector2 activeRange, bool loop, bool selected) { this.UpdateCurveEditorIfNeeded(state); ZoomableArea arg_29_0 = this.m_CurveEditor; float num = this.CalculateTopMargin(animEditorRect.get_height()); this.m_CurveEditor.set_bottommargin(num); arg_29_0.set_topmargin(num); float num2 = state.TimeToPixel((double)this.m_DataSource.start) - animEditorRect.get_xMin(); this.m_CurveEditor.set_rightmargin(0f); this.m_CurveEditor.set_leftmargin(num2); this.m_CurveEditor.set_rect(new Rect(0f, 0f, animEditorRect.get_width(), animEditorRect.get_height())); this.m_CurveEditor.SetShownHRangeInsideMargins(0f, (state.PixelToTime(animEditorRect.get_xMax()) - this.m_DataSource.start) * this.m_DataSource.timeScale); if (this.m_LastFrameRate != state.frameRate) { this.m_CurveEditor.get_hTicks().SetTickModulosForFrameRate(state.frameRate); this.m_LastFrameRate = state.frameRate; } CurveWrapper[] animationCurves = this.m_CurveEditor.get_animationCurves(); for (int i = 0; i < animationCurves.Length; i++) { CurveWrapper curveWrapper = animationCurves[i]; curveWrapper.get_renderer().SetWrap(0, (!loop) ? 0 : 2); } this.m_CurveEditor.BeginViewGUI(); Color color = GUI.get_color(); GUI.set_color(Color.get_white()); GUI.BeginGroup(animEditorRect); Graphics.DrawLine(new Vector2(num2, 0f), new Vector2(num2, animEditorRect.get_height()), new Color(1f, 1f, 1f, 0.5f)); float num3 = activeRange.x - animEditorRect.get_x(); float num4 = activeRange.y - activeRange.x; if (selected) { Rect rect = new Rect(num3, 0f, num4, animEditorRect.get_height()); ClipCurveEditor.DrawOutline(rect, 2f); } EditorGUI.BeginChangeCheck(); Event current = Event.get_current(); if (current.get_type() == 8 || current.get_type() == 7 || selected) { this.m_CurveEditor.CurveGUI(); } this.m_CurveEditor.EndViewGUI(); if (EditorGUI.EndChangeCheck()) { this.OnCurvesUpdated(); } Color colorInlineCurveOutOfRangeOverlay = DirectorStyles.Instance.customSkin.colorInlineCurveOutOfRangeOverlay; Rect rect2 = new Rect(num2, 0f, num3 - num2, animEditorRect.get_height()); EditorGUI.DrawRect(rect2, colorInlineCurveOutOfRangeOverlay); Rect rect3 = new Rect(num3 + num4, 0f, animEditorRect.get_width() - num3 - num4, animEditorRect.get_height()); EditorGUI.DrawRect(rect3, colorInlineCurveOutOfRangeOverlay); GUI.set_color(color); GUI.EndGroup(); Rect rect4 = animEditorRect; rect4.set_width(ClipCurveEditor.s_GridLabelWidth); float num5 = num2 - ClipCurveEditor.s_GridLabelWidth; if (num5 > 0f) { rect4.set_x(animEditorRect.get_x() + num5); } GUI.BeginGroup(rect4); this.m_CurveEditor.GridGUI(); GUI.EndGroup(); }
public bool IsDraggingCurve(CurveWrapper cw) { return this.m_DraggingCurveOrRegion != null && this.m_DraggingCurveOrRegion.Length == 1 && this.m_DraggingCurveOrRegion[0] == cw; }
private void DrawCurves(CurveWrapper[] curves) { if (Event.current.type != EventType.Repaint) { return; } List<CurveSelection> list = (this.m_DisplayedSelection == null) ? this.m_Selection : this.m_DisplayedSelection; for (int i = 0; i < this.m_DrawOrder.Count; i++) { CurveWrapper curveWrapperById = this.getCurveWrapperById(this.m_DrawOrder[i]); if (curveWrapperById != null) { if (!curveWrapperById.hidden) { if (curveWrapperById.curve.length != 0) { CurveWrapper cw = null; if (i < this.m_DrawOrder.Count - 1) { cw = this.getCurveWrapperById(this.m_DrawOrder[i + 1]); } if (this.IsRegion(curveWrapperById, cw)) { i++; bool hasFocus = this.ShouldCurveHaveFocus(i, curveWrapperById, cw); this.DrawCurvesAndRegion(curveWrapperById, cw, (!this.IsRegionCurveSelected(curveWrapperById, cw)) ? null : list, hasFocus); } else { bool hasFocus2 = this.ShouldCurveHaveFocus(i, curveWrapperById, null); this.DrawCurveAndPoints(curveWrapperById, (!this.IsCurveSelected(curveWrapperById)) ? null : list, hasFocus2); } } } } } if (this.m_DraggingCurveOrRegion != null) { return; } HandleUtility.ApplyWireMaterial(); GL.Begin(1); GL.Color(this.m_TangentColor * new Color(1f, 1f, 1f, 0.75f)); foreach (CurveSelection current in list) { if (!current.semiSelected) { Vector2 position = this.GetPosition(current); if (CurveUtility.GetKeyTangentMode(current.keyframe, 0) == TangentMode.Editable && current.keyframe.time != current.curve.keys[0].time) { Vector2 position2 = this.GetPosition(new CurveSelection(current.curveID, this, current.key, CurveSelection.SelectionType.InTangent)); this.DrawLine(position2, position); } if (CurveUtility.GetKeyTangentMode(current.keyframe, 1) == TangentMode.Editable && current.keyframe.time != current.curve.keys[current.curve.keys.Length - 1].time) { Vector2 position3 = this.GetPosition(new CurveSelection(current.curveID, this, current.key, CurveSelection.SelectionType.OutTangent)); this.DrawLine(position, position3); } } } GL.End(); GUI.color = this.m_TangentColor; foreach (CurveSelection current2 in list) { if (!current2.semiSelected) { if (CurveUtility.GetKeyTangentMode(current2.keyframe, 0) == TangentMode.Editable && current2.keyframe.time != current2.curve.keys[0].time) { Vector2 position4 = this.GetPosition(new CurveSelection(current2.curveID, this, current2.key, CurveSelection.SelectionType.InTangent)); this.DrawPoint(position4.x, position4.y, this.ms_Styles.pointIcon); } if (CurveUtility.GetKeyTangentMode(current2.keyframe, 1) == TangentMode.Editable && current2.keyframe.time != current2.curve.keys[current2.curve.keys.Length - 1].time) { Vector2 position5 = this.GetPosition(new CurveSelection(current2.curveID, this, current2.key, CurveSelection.SelectionType.OutTangent)); this.DrawPoint(position5.x, position5.y, this.ms_Styles.pointIcon); } } } if (this.m_DraggingKey != null) { float num = base.vRangeMin; float num2 = base.vRangeMax; num = Mathf.Max(num, this.m_DraggingKey.vRangeMin); num2 = Mathf.Min(num2, this.m_DraggingKey.vRangeMax); Vector2 lhs = this.m_DraggedCoord + this.m_MoveCoord; lhs.x = Mathf.Clamp(lhs.x, base.hRangeMin, base.hRangeMax); lhs.y = Mathf.Clamp(lhs.y, num, num2); Vector2 vector = base.DrawingToViewTransformPoint(lhs); int numberOfDecimalsForMinimumDifference; if (this.invSnap != 0f) { numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference(1f / this.invSnap); } else { numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference(base.shownArea.width / base.drawRect.width); } int numberOfDecimalsForMinimumDifference2 = MathUtils.GetNumberOfDecimalsForMinimumDifference(base.shownArea.height / base.drawRect.height); Vector2 vector2 = (this.m_DraggingKey.getAxisUiScalarsCallback == null) ? Vector2.one : this.m_DraggingKey.getAxisUiScalarsCallback(); if (vector2.x >= 0f) { lhs.x *= vector2.x; } if (vector2.y >= 0f) { lhs.y *= vector2.y; } GUIContent content = new GUIContent(string.Format("{0}, {1}", lhs.x.ToString("N" + numberOfDecimalsForMinimumDifference), lhs.y.ToString("N" + numberOfDecimalsForMinimumDifference2))); Vector2 vector3 = this.ms_Styles.dragLabel.CalcSize(content); EditorGUI.DoDropShadowLabel(new Rect(vector.x, vector.y - vector3.y, vector3.x, vector3.y), content, this.ms_Styles.dragLabel, 0.3f); } }
public bool IsDraggingRegion(CurveWrapper cw1, CurveWrapper cw2) { return this.m_DraggingCurveOrRegion != null && this.m_DraggingCurveOrRegion.Length == 2 && (this.m_DraggingCurveOrRegion[0] == cw1 || this.m_DraggingCurveOrRegion[0] == cw2); }
private void DrawCurvesAndRegion(CurveWrapper cw1, CurveWrapper cw2, List<CurveSelection> selection, bool hasFocus) { this.DrawRegion(cw1, cw2, hasFocus); this.DrawCurveAndPoints(cw1, (!this.IsCurveSelected(cw1)) ? null : selection, hasFocus); this.DrawCurveAndPoints(cw2, (!this.IsCurveSelected(cw2)) ? null : selection, hasFocus); }
private CurveSelection AddKeyframeAndSelect(Keyframe key, CurveWrapper cw) { int num = cw.curve.AddKey(key); CurveUtility.SetKeyModeFromContext(cw.curve, num); CurveUtility.UpdateTangentsFromModeSurrounding(cw.curve, num); CurveSelection result = new CurveSelection(cw.id, this, num); cw.selected = CurveWrapper.SelectionMode.Selected; cw.changed = true; this.activeTime = key.time; return result; }
private void SetConstantCurve(CurveWrapper cw, float constantValue) { Keyframe[] keyframeArray = new Keyframe[1]; keyframeArray[0].time = 0f; keyframeArray[0].value = constantValue; cw.curve.keys = keyframeArray; cw.changed = true; }
private void DrawCurveAndPoints(CurveWrapper cw, List<CurveSelection> selection, bool hasFocus) { this.DrawCurve(cw, hasFocus); this.DrawPointsOnCurve(cw, selection, hasFocus); }
private bool ShouldCurveHaveFocus(int indexIntoDrawOrder, CurveWrapper cw1, CurveWrapper cw2) { bool result = false; if (indexIntoDrawOrder == this.m_DrawOrder.Count - 1) { result = true; } else { if (this.hasSelection) { result = (this.IsCurveSelected(cw1) || this.IsCurveSelected(cw2)); } } return result; }
public override void OnInspectorGUI() { AudioSourceInspector.InitStyles(); base.serializedObject.Update(); if (this.m_LowpassObject != null) { this.m_LowpassObject.Update(); } this.HandleLowPassFilter(); AudioSourceInspector.AudioCurveWrapper[] audioCurves = this.m_AudioCurves; for (int i = 0; i < audioCurves.Length; i++) { AudioSourceInspector.AudioCurveWrapper audioCurveWrapper = audioCurves[i]; CurveWrapper curveWrapperFromID = this.m_CurveEditor.GetCurveWrapperFromID(audioCurveWrapper.id); if (audioCurveWrapper.curveProp != null) { AnimationCurve animationCurveValue = audioCurveWrapper.curveProp.animationCurveValue; if (curveWrapperFromID == null != audioCurveWrapper.curveProp.hasMultipleDifferentValues) { this.m_RefreshCurveEditor = true; } else if (curveWrapperFromID != null) { if (curveWrapperFromID.curve.length == 0) { this.m_RefreshCurveEditor = true; } else if (animationCurveValue.length >= 1 && animationCurveValue.keys[0].value != curveWrapperFromID.curve.keys[0].value) { this.m_RefreshCurveEditor = true; } } } else if (curveWrapperFromID != null) { this.m_RefreshCurveEditor = true; } } this.UpdateWrappersAndLegend(); EditorGUILayout.PropertyField(this.m_AudioClip, AudioSourceInspector.ms_Styles.audioClipLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.PropertyField(this.m_OutputAudioMixerGroup, AudioSourceInspector.ms_Styles.outputMixerGroupLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Mute, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_BypassEffects, new GUILayoutOption[0]); if (base.targets.Any((UnityEngine.Object t) => (t as AudioSource).outputAudioMixerGroup != null)) { using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.PropertyField(this.m_BypassListenerEffects, new GUILayoutOption[0]); } } else { EditorGUILayout.PropertyField(this.m_BypassListenerEffects, new GUILayoutOption[0]); } EditorGUILayout.PropertyField(this.m_BypassReverbZones, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_PlayOnAwake, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Loop, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.priorityLeftLabel, AudioSourceInspector.ms_Styles.priorityRightLabel); EditorGUILayout.IntSlider(this.m_Priority, 0, 256, AudioSourceInspector.ms_Styles.priorityLabel, new GUILayoutOption[0]); EditorGUIUtility.sliderLabels.SetLabels(null, null); EditorGUILayout.Space(); EditorGUILayout.Slider(this.m_Volume, 0f, 1f, AudioSourceInspector.ms_Styles.volumeLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.Slider(this.m_Pitch, -3f, 3f, AudioSourceInspector.ms_Styles.pitchLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.panLeftLabel, AudioSourceInspector.ms_Styles.panRightLabel); EditorGUILayout.Slider(this.m_Pan2D, -1f, 1f, AudioSourceInspector.ms_Styles.panStereoLabel, new GUILayoutOption[0]); EditorGUIUtility.sliderLabels.SetLabels(null, null); EditorGUILayout.Space(); EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.spatialLeftLabel, AudioSourceInspector.ms_Styles.spatialRightLabel); AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.spatialBlendLabel, this.m_AudioCurves[1].curveProp, 0f, 1f, false); EditorGUIUtility.sliderLabels.SetLabels(null, null); EditorGUILayout.Space(); AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.reverbZoneMixLabel, this.m_AudioCurves[4].curveProp, 0f, 1.1f, false); EditorGUILayout.Space(); this.m_Expanded3D = EditorGUILayout.Foldout(this.m_Expanded3D, "3D Sound Settings", true); if (this.m_Expanded3D) { EditorGUI.indentLevel++; this.Audio3DGUI(); EditorGUI.indentLevel--; } if (AudioUtil.canUseSpatializerEffect) { EditorGUILayout.PropertyField(this.m_Spatialize, AudioSourceInspector.ms_Styles.spatializeLabel, new GUILayoutOption[0]); if (this.m_Spatialize.boolValue && !this.m_Spatialize.hasMultipleDifferentValues) { for (int j = 0; j < base.targets.Length; j++) { AudioSource audioSource = base.targets[j] as AudioSource; AudioSourceExtension audioSourceExtension = (!(audioSource != null)) ? null : AudioExtensionManager.GetSpatializerExtension(audioSource); if (audioSource != null && audioSource.spatialize && audioSource.isPlaying) { if (audioSourceExtension == null) { audioSourceExtension = AudioExtensionManager.AddSpatializerExtension(audioSource); } AudioExtensionManager.GetReadyToPlay(audioSourceExtension); } } EditorGUI.indentLevel++; EditorGUILayout.PropertyField(this.m_SpatializePostEffects, AudioSourceInspector.ms_Styles.spatializePostEffectsLabel, new GUILayoutOption[0]); bool flag = (this.m_AddSpatializerExtension && !this.m_AddSpatializerExtensionMixedValues) || !base.serializedObject.isEditingMultipleObjects; if (AudioExtensionManager.IsSourceSpatializerExtensionRegistered() && flag) { EditorGUI.showMixedValue = this.m_AddSpatializerExtensionMixedValues; bool flag2 = EditorGUILayout.Toggle(AudioSourceInspector.ms_Styles.addSpatializerExtensionLabel, this.m_AddSpatializerExtension, new GUILayoutOption[0]); EditorGUI.showMixedValue = false; bool flag3 = false; if (this.m_AddSpatializerExtension != flag2) { this.m_AddSpatializerExtension = flag2; if (this.m_AddSpatializerExtension) { this.CreateExtensionEditors(); if (this.m_SpatializerEditor != null) { flag3 = this.m_SpatializerEditor.FindAudioExtensionProperties(base.serializedObject); } } else { this.ClearExtensionProperties(); this.DestroyExtensionEditors(); flag3 = false; } } else if (this.m_SpatializerEditor != null) { flag3 = this.m_SpatializerEditor.FindAudioExtensionProperties(base.serializedObject); if (!flag3) { this.m_AddSpatializerExtension = false; this.ClearExtensionProperties(); this.DestroyExtensionEditors(); } } if (this.m_SpatializerEditor != null && flag3) { EditorGUI.indentLevel++; this.m_SpatializerEditor.OnAudioSourceGUI(); EditorGUI.indentLevel--; for (int k = 0; k < base.targets.Length; k++) { AudioSource audioSource2 = base.targets[k] as AudioSource; AudioSourceExtension audioSourceExtension2 = (!(audioSource2 != null)) ? null : AudioExtensionManager.GetSpatializerExtension(audioSource2); if (audioSource2 != null && audioSourceExtension2 != null && audioSource2.isPlaying) { string name = AudioExtensionManager.GetSourceSpatializerExtensionType().Name; for (int l = 0; l < this.m_SpatializerEditor.GetNumExtensionProperties(); l++) { PropertyName extensionPropertyName = this.m_SpatializerEditor.GetExtensionPropertyName(l); float propertyValue = 0f; if (audioSource2.ReadExtensionProperty(name, extensionPropertyName, ref propertyValue)) { audioSourceExtension2.WriteExtensionProperty(extensionPropertyName, propertyValue); } } } } } } } } base.serializedObject.ApplyModifiedProperties(); if (this.m_LowpassObject != null) { this.m_LowpassObject.ApplyModifiedProperties(); } }