void LayoutInfoPanel(Rect rect) { GUILayout.BeginArea(rect, EditorStyles.inspectorFullWidthMargins); GUILayout.Space(20); // Animation length EditorGUILayout.LabelField(string.Format("Length: {0:0.00} sec {1:D} samples", m_clip.length, Mathf.RoundToInt(m_clip.length / GetMinFrameTime())), new GUIStyle(EditorStyles.miniLabel) { normal = { textColor = Color.gray } }); // Speed/Framerate GUI.SetNextControlName("Framerate"); float newFramerate = EditorGUILayout.DelayedFloatField("Sample Rate", m_clip.frameRate); if (Mathf.Approximately(newFramerate, m_clip.frameRate) == false) { ChangeFrameRate(newFramerate, true); } GUI.SetNextControlName("Length"); float oldLength = Utils.Snap(m_clip.length, 0.05f); float newLength = Utils.Snap(EditorGUILayout.FloatField("Length (sec)", oldLength), 0.05f); if (Mathf.Approximately(newLength, oldLength) == false && newLength > 0) { newFramerate = Mathf.Max(Utils.Snap((m_clip.frameRate * (m_clip.length / newLength)), 1), 1); ChangeFrameRate(newFramerate, false); } // Looping tickbox bool looping = EditorGUILayout.Toggle("Looping", m_clip.isLooping); if (looping != m_clip.isLooping) { ChangeLooping(looping); } // UI Image option- Done as an enum to be clearer eAnimSpriteType animSpriteType = (eAnimSpriteType)EditorGUILayout.EnumPopup("Animated Sprite Type", m_uiImage ? eAnimSpriteType.UIImage : eAnimSpriteType.Sprite); SetIsUIImage(animSpriteType == eAnimSpriteType.UIImage); GUILayout.Space(10); // Frames list m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition, false, false); EditorGUI.BeginChangeCheck(); m_framesReorderableList.DoLayoutList(); if (EditorGUI.EndChangeCheck()) { RecalcFrameTimes(); Repaint(); ApplyChanges(); } EditorGUILayout.EndScrollView(); GUILayout.EndArea(); }
void LayoutInfoPanel(Rect rect) { GUILayout.BeginArea(rect, EditorStyles.inspectorFullWidthMargins); GUILayout.Space(20); // Animation length EditorGUILayout.LabelField(string.Format("Length: {0:0.00} sec {1:D} samples", m_clip.length, Mathf.RoundToInt(m_clip.length / GetMinFrameTime())), new GUIStyle(EditorStyles.miniLabel) { normal = { textColor = Color.gray } }); // Speed/Framerate GUI.SetNextControlName("Framerate"); float newFramerate = EditorGUILayout.DelayedFloatField("Sample Rate", m_clip.frameRate); if (Mathf.Approximately(newFramerate, m_clip.frameRate) == false) { ChangeFrameRate(newFramerate, true); } GUI.SetNextControlName("Length"); float oldLength = Utils.Snap(m_clip.length, 0.001f); float newLength = Utils.Snap(EditorGUILayout.FloatField("Length (sec)", oldLength), 0.001f); if (Mathf.Approximately(newLength, oldLength) == false && newLength > 0) { newFramerate = Mathf.Max(Utils.Snap((m_clip.frameRate * (m_clip.length / newLength)), 1), 1); ChangeFrameRate(newFramerate, false); } // Looping tickbox bool looping = EditorGUILayout.Toggle("Looping", m_clip.isLooping); if (looping != m_clip.isLooping) { ChangeLooping(looping); } // UI Image option- Done as an enum to be clearer eAnimSpriteType animSpriteType = (eAnimSpriteType)EditorGUILayout.EnumPopup("Animated Sprite Type", m_uiImage ? eAnimSpriteType.UIImage : eAnimSpriteType.Sprite); SetIsUIImage(animSpriteType == eAnimSpriteType.UIImage); // Path to sprite in game object if (m_showAdvancedOptions) { SetSpritePath(EditorGUILayout.DelayedTextField("Sprite Path", m_spritePath)); } GUILayout.Space(10); // Frames list m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition, false, false); EditorGUI.BeginChangeCheck(); m_framesReorderableList.DoLayoutList(); if (EditorGUI.EndChangeCheck()) { RecalcFrameTimes(); Repaint(); ApplyChanges(); } m_settingsUnfolded = EditorGUILayout.Foldout(m_settingsUnfolded, "Editor Settings", new GUIStyle(EditorStyles.foldout) { normal = { textColor = Color.gray } }); if (m_settingsUnfolded) { string[] nodeNames = new string[m_defaultNodeNames.Length]; for (int i = 0; i < nodeNames.Length; ++i) { nodeNames[i] = string.IsNullOrEmpty(m_defaultNodeNames[i]) ? ("Node " + i) : m_defaultNodeNames[i]; } m_visibleNodes = EditorGUILayout.MaskField("Visible Nodes", m_visibleNodes, nodeNames); GUI.SetNextControlName("AvdOpt"); m_showAdvancedOptions = EditorGUILayout.Toggle("Show Advanced Options", m_showAdvancedOptions); GUI.SetNextControlName("DefaultLen"); m_defaultFrameLength = EditorGUILayout.DelayedFloatField("Default Frame Length", m_defaultFrameLength); GUI.SetNextControlName("DefaultSamples"); m_defaultFrameSamples = EditorGUILayout.DelayedIntField("Default Frame Samples", m_defaultFrameSamples); GUI.SetNextControlName("IgnorePivot"); m_ignorePivot = EditorGUILayout.Toggle("Ignore Pivot", m_ignorePivot); GUILayout.Space(20); } EditorGUILayout.EndScrollView(); GUILayout.EndArea(); }