private static void GUICurveField(Rect position, SerializedProperty maxCurve, SerializedProperty minCurve, Color color, Rect ranges, CurveFieldMouseDownCallback mouseDownCallback) { int controlID = GUIUtility.GetControlID(0x4ec1c30f, FocusType.Keyboard, position); Event current = Event.current; EventType typeForControl = current.GetTypeForControl(controlID); if (typeForControl == EventType.Repaint) { Rect rect = position; if (minCurve == null) { EditorGUIUtility.DrawCurveSwatch(rect, null, maxCurve, color, EditorGUI.kCurveBGColor, ranges); } else { EditorGUIUtility.DrawRegionSwatch(rect, maxCurve, minCurve, color, EditorGUI.kCurveBGColor, ranges); } EditorStyles.colorPickerBox.Draw(rect, GUIContent.none, controlID, false); } else if (typeForControl == EventType.ValidateCommand) { if (current.commandName == "UndoRedoPerformed") { AnimationCurvePreviewCache.ClearCache(); } } else if ((typeForControl == EventType.MouseDown) && (position.Contains(current.mousePosition) && ((mouseDownCallback != null) && mouseDownCallback(current.button, position, ranges)))) { current.Use(); } }
private void SaveChangedCurves() { CurveWrapper[] animationCurves = this.m_CurveEditor.animationCurves; bool flag = false; for (int index1 = 0; index1 < animationCurves.Length; ++index1) { CurveWrapper cw = animationCurves[index1]; if (cw.changed) { for (int index2 = 0; index2 < this.m_AddedCurves.Count; ++index2) { if (this.m_AddedCurves[index2].m_MaxId == cw.id) { this.SaveCurve(this.m_AddedCurves[index2].m_Max, cw); break; } if (this.m_AddedCurves[index2].IsRegion() && this.m_AddedCurves[index2].m_MinId == cw.id) { this.SaveCurve(this.m_AddedCurves[index2].m_Min, cw); break; } } flag = true; } } if (!flag) { return; } AnimationCurvePreviewCache.ClearCache(); HandleUtility.Repaint(); }
private void SaveChangedCurves() { CurveWrapper[] animationCurves = this.m_CurveEditor.animationCurves; bool flag = false; for (int i = 0; i < animationCurves.Length; i++) { CurveWrapper curveWrapper = animationCurves[i]; if (curveWrapper.changed) { for (int j = 0; j < this.m_AddedCurves.Count; j++) { if (this.m_AddedCurves[j].m_MaxId == curveWrapper.id) { this.SaveCurve(this.m_AddedCurves[j].m_Max, curveWrapper); break; } if (this.m_AddedCurves[j].IsRegion() && this.m_AddedCurves[j].m_MinId == curveWrapper.id) { this.SaveCurve(this.m_AddedCurves[j].m_Min, curveWrapper); break; } } flag = true; } } if (flag) { AnimationCurvePreviewCache.ClearCache(); HandleUtility.Repaint(); } }
private static void DrawCurveSwatchInternal(Rect position, AnimationCurve curve, AnimationCurve curve2, SerializedProperty property, SerializedProperty property2, Color color, Color bgColor, bool useCurveRanges, Rect curveRanges) { if (Event.current.type != EventType.Repaint) { return; } int previewWidth = (int)position.width; int previewHeight = (int)position.height; Color color2 = GUI.color; GUI.color = bgColor; GUIStyle gUIStyle = EditorGUIUtility.whiteTextureStyle; gUIStyle.Draw(position, false, false, false, false); GUI.color = color2; if (property != null && property.hasMultipleDifferentValues) { EditorGUI.BeginHandleMixedValueContentColor(); GUI.Label(position, EditorGUI.mixedValueContent, "PreOverlayLabel"); EditorGUI.EndHandleMixedValueContentColor(); } else { Texture2D texture2D = null; if (property != null) { if (property2 == null) { texture2D = ((!useCurveRanges) ? AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, property, color) : AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, property, color, curveRanges)); } else { texture2D = ((!useCurveRanges) ? AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, property, property2, color) : AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, property, property2, color, curveRanges)); } } else { if (curve != null) { if (curve2 == null) { texture2D = ((!useCurveRanges) ? AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, curve, color) : AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, curve, color, curveRanges)); } else { texture2D = ((!useCurveRanges) ? AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, curve, curve2, color) : AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, curve, curve2, color, curveRanges)); } } } gUIStyle = EditorGUIUtility.GetBasicTextureStyle(texture2D); position.width = (float)texture2D.width; position.height = (float)texture2D.height; gUIStyle.Draw(position, false, false, false, false); } }
public void SetMinMaxState(MinMaxCurveState newState, bool addToCurveEditor = true) { if (!this.stateHasMultipleDifferentValues) { if (newState == this.state) { return; } } MinMaxCurveState state = this.state; ParticleSystemCurveEditor particleSystemCurveEditor = this.m_Module.GetParticleSystemCurveEditor(); if (particleSystemCurveEditor.IsAdded(this.GetMinCurve(), this.maxCurve)) { particleSystemCurveEditor.RemoveCurve(this.GetMinCurve(), this.maxCurve); } switch (newState) { case MinMaxCurveState.k_Scalar: this.InitSingleScalar(state); break; case MinMaxCurveState.k_Curve: this.InitSingleCurve(state); break; case MinMaxCurveState.k_TwoCurves: this.InitDoubleCurves(state); break; case MinMaxCurveState.k_TwoScalars: this.InitDoubleScalars(state); break; } this.minMaxState.intValue = (int)newState; if (addToCurveEditor) { switch (newState) { case MinMaxCurveState.k_Scalar: case MinMaxCurveState.k_TwoScalars: break; case MinMaxCurveState.k_Curve: case MinMaxCurveState.k_TwoCurves: particleSystemCurveEditor.AddCurve(this.CreateCurveData(particleSystemCurveEditor.GetAvailableColor())); break; default: Debug.LogError("Unhandled enum value"); break; } } AnimationCurvePreviewCache.ClearCache(); }
private void OnBurstListRemoveCallback(ReorderableList list) { for (int i = list.index; i < this.m_BurstCountCurves.Count; i++) { this.m_BurstCountCurves[i].RemoveCurveFromEditor(); } this.m_BurstCountCurves.RemoveRange(list.index, this.m_BurstCountCurves.Count - list.index); AnimationCurvePreviewCache.ClearCache(); ReorderableList.defaultBehaviours.DoRemoveButton(list); this.m_BurstCount.intValue--; }
private void OnBurstListRemoveCallback(ReorderableList list) { // All subsequent curves must be removed from the curve editor, as their indices will change, which means their SerializedProperty paths will also change for (int i = list.index; i < m_BurstCountCurves.Count; i++) { m_BurstCountCurves[i].RemoveCurveFromEditor(); } m_BurstCountCurves.RemoveRange(list.index, m_BurstCountCurves.Count - list.index); AnimationCurvePreviewCache.ClearCache(); // Default remove behavior ReorderableList.defaultBehaviours.DoRemoveButton(list); m_BurstCount.intValue--; }
void SyncClipEditor(AnimationClipInfoProperties info) { if (m_AnimationClipEditor == null || m_MaskInspector == null) { return; } // It mandatory to set clip info into mask inspector first, this will update m_Mask. m_MaskInspector.clipInfo = info; m_AnimationClipEditor.ShowRange(info); m_AnimationClipEditor.mask = m_Mask; AnimationCurvePreviewCache.ClearCache(); }
private void SetMinMaxState(MinMaxCurveState newState) { if (newState == this.state) { return; } MinMaxCurveState state = this.state; ParticleSystemCurveEditor systemCurveEditor = this.m_Module.GetParticleSystemCurveEditor(); if (systemCurveEditor.IsAdded(this.GetMinCurve(), this.maxCurve)) { systemCurveEditor.RemoveCurve(this.GetMinCurve(), this.maxCurve); } switch (newState) { case MinMaxCurveState.k_Scalar: this.InitSingleScalar(state); break; case MinMaxCurveState.k_Curve: this.InitSingleCurve(state); break; case MinMaxCurveState.k_TwoCurves: this.InitDoubleCurves(state); break; case MinMaxCurveState.k_TwoScalars: this.InitDoubleScalars(state); break; } this.minMaxState.intValue = (int)newState; switch (newState) { case MinMaxCurveState.k_Scalar: case MinMaxCurveState.k_TwoScalars: AnimationCurvePreviewCache.ClearCache(); break; case MinMaxCurveState.k_Curve: case MinMaxCurveState.k_TwoCurves: systemCurveEditor.AddCurve(this.CreateCurveData(systemCurveEditor.GetAvailableColor())); goto case MinMaxCurveState.k_Scalar; default: Debug.LogError((object)"Unhandled enum value"); goto case MinMaxCurveState.k_Scalar; } }
private static void DrawCurveSwatchInternal(Rect position, AnimationCurve curve, AnimationCurve curve2, SerializedProperty property, SerializedProperty property2, Color color, Color bgColor, bool useCurveRanges, Rect curveRanges) { if (Event.current.type == EventType.Repaint) { int width = (int)position.width; int height = (int)position.height; Color color2 = GUI.color; GUI.color = bgColor; whiteTextureStyle.Draw(position, false, false, false, false); GUI.color = color2; if ((property != null) && property.hasMultipleDifferentValues) { EditorGUI.BeginHandleMixedValueContentColor(); GUI.Label(position, EditorGUI.mixedValueContent, "PreOverlayLabel"); EditorGUI.EndHandleMixedValueContentColor(); } else { Texture2D tex = null; if (property != null) { if (property2 == null) { tex = !useCurveRanges?AnimationCurvePreviewCache.GetPreview(width, height, property, color) : AnimationCurvePreviewCache.GetPreview(width, height, property, color, curveRanges); } else { tex = !useCurveRanges?AnimationCurvePreviewCache.GetPreview(width, height, property, property2, color) : AnimationCurvePreviewCache.GetPreview(width, height, property, property2, color, curveRanges); } } else if (curve != null) { if (curve2 == null) { tex = !useCurveRanges?AnimationCurvePreviewCache.GetPreview(width, height, curve, color) : AnimationCurvePreviewCache.GetPreview(width, height, curve, color, curveRanges); } else { tex = !useCurveRanges?AnimationCurvePreviewCache.GetPreview(width, height, curve, curve2, color) : AnimationCurvePreviewCache.GetPreview(width, height, curve, curve2, color, curveRanges); } } GUIStyle basicTextureStyle = GetBasicTextureStyle(tex); position.width = tex.width; position.height = tex.height; basicTextureStyle.Draw(position, false, false, false, false); } } }
public void SetMinMaxState(MinMaxCurveState newState, bool addToCurveEditor) { if (this.stateHasMultipleDifferentValues) { Debug.LogError("SetMinMaxState is not allowed with multiple different values"); } else if (newState != this.state) { MinMaxCurveState state = this.state; ParticleSystemCurveEditor particleSystemCurveEditor = this.m_Module.GetParticleSystemCurveEditor(); if (particleSystemCurveEditor.IsAdded(this.GetMinCurve(), this.maxCurve)) { particleSystemCurveEditor.RemoveCurve(this.GetMinCurve(), this.maxCurve); } if (newState != MinMaxCurveState.k_Curve) { if (newState == MinMaxCurveState.k_TwoCurves) { this.SetCurveRequirements(); } } else { this.SetCurveRequirements(); } this.minMaxState.intValue = (int)newState; if (addToCurveEditor) { switch (newState) { case MinMaxCurveState.k_Scalar: case MinMaxCurveState.k_TwoScalars: break; case MinMaxCurveState.k_Curve: case MinMaxCurveState.k_TwoCurves: particleSystemCurveEditor.AddCurve(this.CreateCurveData(particleSystemCurveEditor.GetAvailableColor())); break; default: Debug.LogError("Unhandled enum value"); break; } } AnimationCurvePreviewCache.ClearCache(); } }
void SetupStandardRepaint() { if (!m_TextureDirty) { return; } m_TextureDirty = false; int previewWidth = (int)visualInput.layout.width; int previewHeight = (int)visualInput.layout.height; // The default range is (0,0,-1,-1), see AnimationCurvePreviewCache.cpp // This will mimic the IMGUI curve since the range will be calculated by the CurvePreview if the range is at the default value... Rect rangeRect = new Rect(0, 0, -1, -1); // We assign the ranges if different than the Rect() default value if (ranges.width > 0 && ranges.height > 0) { rangeRect = ranges; } if (previewHeight > 1 && previewWidth > 1) { if (!m_ValueNull) { m_Texture = AnimationCurvePreviewCache.GenerateCurvePreview( previewWidth, previewHeight, rangeRect, rawValue, curveColor, m_Texture); } else { m_Texture = null; } } }
private static void GUICurveField(Rect position, SerializedProperty maxCurve, SerializedProperty minCurve, Color color, Rect ranges, ModuleUI.CurveFieldMouseDownCallback mouseDownCallback) { int controlId = GUIUtility.GetControlID(1321321231, EditorGUIUtility.native, position); Event current = Event.current; switch (current.GetTypeForControl(controlId)) { case EventType.MouseDown: if (!position.Contains(current.mousePosition) || mouseDownCallback == null || !mouseDownCallback(current.button, position, ranges)) { break; } current.Use(); break; case EventType.Repaint: Rect position1 = position; if (minCurve == null) { EditorGUIUtility.DrawCurveSwatch(position1, (AnimationCurve)null, maxCurve, color, EditorGUI.kCurveBGColor, ranges); } else { EditorGUIUtility.DrawRegionSwatch(position1, maxCurve, minCurve, color, EditorGUI.kCurveBGColor, ranges); } EditorStyles.colorPickerBox.Draw(position1, GUIContent.none, controlId, false); break; case EventType.ValidateCommand: if (!(current.commandName == "UndoRedoPerformed")) { break; } AnimationCurvePreviewCache.ClearCache(); break; } }
public override void DoRepaint() { if (this.m_TextureDirty) { this.m_TextureDirty = false; int num = (int)base.layout.width; int num2 = (int)base.layout.height; Rect curveRanges = new Rect(0f, 0f, 1f, 1f); if (this.ranges.width > 0f && this.ranges.height > 0f) { curveRanges = this.ranges; } else if (!this.m_ValueNull && this.m_Value.keys.Length > 1) { float num3 = float.PositiveInfinity; float num4 = float.PositiveInfinity; float num5 = float.NegativeInfinity; float num6 = float.NegativeInfinity; for (int i = 0; i < this.m_Value.keys.Length; i++) { float value = this.m_Value.keys[i].value; float time = this.m_Value.keys[i].time; if (num3 > time) { num3 = time; } if (num5 < time) { num5 = time; } if (num4 > value) { num4 = value; } if (num6 < value) { num6 = value; } } if (num4 == num6) { num6 = num4 + 1f; } if (num3 == num5) { num5 = num3 + 1f; } curveRanges = Rect.MinMaxRect(num3, num4, num5, num6); } if (num2 > 0 && num > 0) { if (!this.m_ValueNull) { base.style.backgroundImage = AnimationCurvePreviewCache.GenerateCurvePreview(num, num2, curveRanges, this.m_Value, this.curveColor, base.style.backgroundImage.value); } else { base.style.backgroundImage = null; } } } base.DoRepaint(); }
private static void DrawCurveSwatchInternal(Rect position, AnimationCurve curve, AnimationCurve curve2, SerializedProperty property, SerializedProperty property2, Color color, Color bgColor, bool useCurveRanges, Rect curveRanges, Color topFillColor, Color bottomFillColor) { if (Event.current.type != EventType.Repaint) { return; } int num = (int)position.width; int num2 = (int)position.height; int maxTextureSize = SystemInfo.maxTextureSize; bool flag = num > maxTextureSize; bool flag2 = num2 > maxTextureSize; if (flag) { num = Mathf.Min(num, maxTextureSize); } if (flag2) { num2 = Mathf.Min(num2, maxTextureSize); } Color color2 = GUI.color; GUI.color = bgColor; GUIStyle gUIStyle = EditorGUIUtility.whiteTextureStyle; gUIStyle.Draw(position, false, false, false, false); GUI.color = color2; if (property != null && property.hasMultipleDifferentValues) { EditorGUI.BeginHandleMixedValueContentColor(); GUI.Label(position, EditorGUI.mixedValueContent, "PreOverlayLabel"); EditorGUI.EndHandleMixedValueContentColor(); } else { Texture2D texture2D = null; if (property != null) { if (property2 == null) { texture2D = ((!useCurveRanges) ? AnimationCurvePreviewCache.GetPreview(num, num2, property, color, topFillColor, bottomFillColor) : AnimationCurvePreviewCache.GetPreview(num, num2, property, color, topFillColor, bottomFillColor, curveRanges)); } else { texture2D = ((!useCurveRanges) ? AnimationCurvePreviewCache.GetPreview(num, num2, property, property2, color, topFillColor, bottomFillColor) : AnimationCurvePreviewCache.GetPreview(num, num2, property, property2, color, topFillColor, bottomFillColor, curveRanges)); } } else if (curve != null) { if (curve2 == null) { texture2D = ((!useCurveRanges) ? AnimationCurvePreviewCache.GetPreview(num, num2, curve, color, topFillColor, bottomFillColor) : AnimationCurvePreviewCache.GetPreview(num, num2, curve, color, topFillColor, bottomFillColor, curveRanges)); } else { texture2D = ((!useCurveRanges) ? AnimationCurvePreviewCache.GetPreview(num, num2, curve, curve2, color, topFillColor, bottomFillColor) : AnimationCurvePreviewCache.GetPreview(num, num2, curve, curve2, color, topFillColor, bottomFillColor, curveRanges)); } } gUIStyle = EditorGUIUtility.GetBasicTextureStyle(texture2D); if (!flag) { position.width = (float)texture2D.width; } if (!flag2) { position.height = (float)texture2D.height; } gUIStyle.Draw(position, false, false, false, false); } }
public void Refresh() { this.ContentChanged(); AnimationCurvePreviewCache.ClearCache(); }
void RefreshCurves() { AnimationCurvePreviewCache.ClearCache(); TimelineWindow.RepaintIfEditingTimelineAsset(m_TimelineAsset); Repaint(); }
void SetupStandardRepaint() { if (!m_TextureDirty) { return; } m_TextureDirty = false; int previewWidth = (int)layout.width; int previewHeight = (int)layout.height; Rect rangeRect = new Rect(0, 0, 1, 1); if (ranges.width > 0 && ranges.height > 0) { rangeRect = ranges; } else if (!m_ValueNull && m_Value.keys.Length > 1) { float xMin = Mathf.Infinity; float yMin = Mathf.Infinity; float xMax = -Mathf.Infinity; float yMax = -Mathf.Infinity; for (int i = 0; i < m_Value.keys.Length; ++i) { float y = m_Value.keys[i].value; float x = m_Value.keys[i].time; if (xMin > x) { xMin = x; } if (xMax < x) { xMax = x; } if (yMin > y) { yMin = y; } if (yMax < y) { yMax = y; } } if (yMin == yMax) { yMax = yMin + 1; } if (xMin == xMax) { xMax = xMin + 1; } rangeRect = Rect.MinMaxRect(xMin, yMin, xMax, yMax); } if (previewHeight > 0 && previewWidth > 0) { if (!m_ValueNull) { style.backgroundImage = AnimationCurvePreviewCache.GenerateCurvePreview( previewWidth, previewHeight, rangeRect, m_Value, curveColor, style.backgroundImage.value); } else { style.backgroundImage = null; } } }