//--------------------------------------------------------------------------------------------- // // ShowZoom // Show current Zoom and also buttons for changing it // //--------------------------------------------------------------------------------------------- void ShowZoom() { GUIEditorUtils.LookLikeControls(40); EditorGUILayout.BeginHorizontal(); m_ZoomFactor = EditorGUILayout.IntField("Zoom", Mathf.RoundToInt(m_ZoomFactor * 100.0f), GUILayout.Width(75)) / 100.0f; GUI.SetNextControlName("ZoomButtons"); switch (GUILayout.Toolbar(-1, m_ZoomButtonsSelStrings, GUILayout.Width(50))) { case 0: m_ZoomFactor += 0.01f; GUI.FocusControl("ZoomButtons"); break; case 1: m_ZoomFactor -= 0.01f; GUI.FocusControl("ZoomButtons"); break; } m_ZoomFactor = Mathf.Clamp(m_ZoomFactor, GUIEditorUtils.MIN_SCALE_FACTOR, GUIEditorUtils.MAX_SCALE_FACTOR); EditorGUILayout.EndHorizontal(); GUIEditorUtils.LookLikeControls(m_DefaultLabelWidth); }
void OnGUI() { GUIEditorUtils.LookLikeControls(); EditorGUI.BeginChangeCheck(); m_ImageType = (ImageType)EditorGUILayout.EnumPopup("Choose file format : ", m_ImageType); switch (m_ImageType) { case ImageType.JPG: m_JPEGQuality = EditorGUILayout.IntField("JPEG quality (25-100) %", m_JPEGQuality); m_JPEGQuality = Mathf.Clamp(m_JPEGQuality, 25, 100); break; case ImageType.SUPERSIZED_PNG: m_Supersize = EditorGUILayout.IntField("Supersize (1-100) ", m_Supersize); m_Supersize = Mathf.Clamp(m_Supersize, 1, 100); break; } if (EditorGUI.EndChangeCheck()) { SaveInEditorPrefs(); } //GUIEditorUtils.LookLikeInspector(); GUILayout.FlexibleSpace(); GUILayout.Label("Note : for taking screenshot out of game mode\nplease use 'SUPERSIZED_PNG' mode."); GUILayout.Space(10); }
void RenderTopPanel() { GUIEditorUtils.LookLikeControls(); EditorGUILayout.BeginHorizontal(GUILayout.Height(28)); GUILayout.FlexibleSpace(); ShowZoom(); EditorGUILayout.Separator(); EditorGUILayout.EndVertical(); }
// Implement your own editor GUI here. void OnGUI() { GUIEditorUtils.LookLikeControls(); //base ragdoll field GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Base Ragdoll:", GUILayout.Width(95), GUILayout.ExpandWidth(false)); BaseRagdoll = (GameObject)EditorGUILayout.ObjectField(BaseRagdoll, typeof(GameObject), true, GUILayout.Width(220), GUILayout.ExpandWidth(false)); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); //clone button EditorGUILayout.BeginHorizontal("box"); GUILayout.Label("", GUILayout.Width(90), GUILayout.ExpandWidth(false)); UnityEngine.Object[] activeGOs = Selection.GetFiltered(typeof(AgentHuman), SelectionMode.Editable | SelectionMode.TopLevel); string caption = ("Clone To Selection: " + activeGOs.Length + (activeGOs.Length == 1 ? " object" : " objects")); if (GUILayout.Button(caption, GUILayout.Width(200))) //beny: possible to use also GUILayout.ExpandWidth(false), but absolute width is better for this { CloneToSelection(); } GUILayout.Label("", GUILayout.Width(100), GUILayout.ExpandWidth(false)); GUILayout.Space(20); EditorGUILayout.EndHorizontal(); GUI.changed = false; // if (GUI.changed) { //check the base ragdoll if (BaseRagdoll) { AgentHuman agent = BaseRagdoll.GetComponent <AgentHuman>(); if (!agent || !agent.RagdollRoot) //do not allow other objects to be picked in { BaseRagdoll = null; this.Repaint(); } } } }
public static float Axis(Rect pos, SerializedProperty prop, string label) { GUIEditorUtils.LookLikeControls(20); EditorGUI.BeginChangeCheck(); float result = EditorGUI.FloatField(pos, label, prop.floatValue); if (EditorGUI.EndChangeCheck() == true) { prop.floatValue = result; } GUIEditorUtils.LookLikeInspector(); return(result); }
//--------------------------------------------------------------------------------------------- // // ShowWidgetParams // Show UV and size of selected widget // //--------------------------------------------------------------------------------------------- void ShowWidgetParams() { // // Enable modification of U,V,Width,Height // int u = Mathf.RoundToInt(m_EditedArea.Area.x); int v = Mathf.RoundToInt(m_EditedArea.Area.y); int w = Mathf.RoundToInt((m_EditedArea.Area.x + m_EditedArea.Area.width) - u); int h = Mathf.RoundToInt((m_EditedArea.Area.y + m_EditedArea.Area.height) - v); int oldU = u; int oldV = v; int oldW = w; int oldH = h; Texture texture = m_SelectedWidget ? m_SelectedWidget.GetTexture() : null; int texWidth = texture ? texture.width : 1024; int texHeight = texture ? texture.height : 1024; EditorGUILayout.BeginVertical(); GUIEditorUtils.LookLikeControls(20); EditorGUILayout.LabelField("Mapping", EditorStyles.boldLabel); u = EditorGUILayout.IntSlider("U", u, -texWidth, texWidth * 2); v = EditorGUILayout.IntSlider("V", v, -texHeight, texHeight * 2); w = EditorGUILayout.IntSlider("W", w, -texWidth, texWidth); h = EditorGUILayout.IntSlider("H", h, -texHeight, texHeight); GUIEditorUtils.LookLikeControls(m_DefaultLabelWidth); EditorGUILayout.EndVertical(); if (m_SelectedWidget) { m_EditedArea.Area.x = u; m_EditedArea.Area.y = v; m_EditedArea.Area.width = w; m_EditedArea.Area.height = h; bool dirtyFlag = (oldU != u) || (oldV != v) || (oldW != w) || (oldH != h); UpdateWidgetByArea(m_SelectedWidget, m_EditedArea, dirtyFlag); } }
//--------------------------------------------------------------------------------------------- // // Show Left Panel // - parameters of selected widget // - zoom buttons // - etc. // //--------------------------------------------------------------------------------------------- void RenderLeftPanel() { GUIEditorUtils.LookLikeControls(m_DefaultLabelWidth); // Show left panel with params m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos, GUILayout.Width(290)); EditorGUILayout.BeginVertical(); GUI.enabled = m_SelectedWidget ? true : false; // Edit widget params ShowWidgetParams(); EditorGUILayout.Separator(); ShowGrid9Params(); EditorGUILayout.Separator(); ShowCopyPaste(); EditorGUILayout.Separator(); GUI.enabled = true; EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
// Implement your own editor GUI here. void OnGUI() { GUIEditorUtils.LookLikeControls(); if (m_EditableObjects == null) { GUILayout.Space(30); EditorGUILayout.BeginHorizontal("box"); GUILayout.Label("Select object(s) that you want to see animated first..."); GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh", GUILayout.Width(78))) { RefreshContent(); } EditorGUILayout.EndHorizontal(); return; } //update the slider time... m_MaxSliderTime = 0; EditorGUILayout.BeginHorizontal(); bool OldGUI = GUI.enabled; GUI.enabled = false; GUILayout.Label("Target", GUILayout.Width(150), GUILayout.ExpandWidth(false)); GUILayout.Label("Animation", GUILayout.Width(200), GUILayout.ExpandWidth(false)); GUILayout.Label("Length", GUILayout.Width(75), GUILayout.ExpandWidth(false)); GUILayout.Label("Speed", GUILayout.Width(75), GUILayout.ExpandWidth(false)); //GUILayout.Space(2*kPlsuMinusWidth); //GUILayout.Space(kPlsuMinusWidth); //GUILayout.Space(kPlsuMinusWidth); GUI.enabled = OldGUI; EditorGUILayout.EndHorizontal(); //display tracks per object and update m_MaxSliderTime foreach (AnimTrack track in m_EditableObjects) { if (track != null && track.m_GameObject != null) { EditorGUILayout.BeginHorizontal("", GUILayout.MaxHeight(11)); GUILayout.Label(track.m_GameObject.name, GUILayout.Width(150), GUILayout.ExpandWidth(false)); track.m_Animation = (AnimationClip)EditorGUILayout.ObjectField(track.m_Animation, typeof(AnimationClip), false, GUILayout.Width(200), GUILayout.ExpandWidth(false)); string animLength = (track.m_Animation != null) ? track.m_Animation.length.ToString("F3") : " -- "; GUILayout.Label(animLength, GUILayout.Width(75), GUILayout.ExpandWidth(false)); track.m_Speed = EditorGUILayout.FloatField(track.m_Speed, GUILayout.Width(75), GUILayout.ExpandWidth(false)); float trackSpeed = (track.m_Animation == null || track.m_Speed <= 0.001) ? 0.0f : track.m_Animation.length / track.m_Speed; m_MaxSliderTime = Mathf.Max(m_MaxSliderTime, trackSpeed); track.m_Delay = EditorGUILayout.FloatField(track.m_Delay, GUILayout.Width(75), GUILayout.ExpandWidth(false)); m_MaxSliderTime = Mathf.Max(m_MaxSliderTime, m_MaxSliderTime + track.m_Delay); EditorGUILayout.EndHorizontal(); } } GUILayout.Space(10); EditorGUILayout.BeginHorizontal("box"); if (GUILayout.Button("Play", GUILayout.Width(78))) //beny: possible to use also GUILayout.ExpandWidth(false), but absolute width is better for this { m_AnimTime = 0; m_LastUpdateTime = Time.realtimeSinceStartup; m_IsPlaying = true; } if (GUILayout.Button("Stop", GUILayout.Width(78))) { m_AnimTime = 0; m_LastUpdateTime = 0; m_IsPlaying = false; } if (GUILayout.Button("Pause", GUILayout.Width(78))) { m_IsPlaying = !m_IsPlaying; m_LastUpdateTime = Time.realtimeSinceStartup; } GUILayout.Space(20); GUILayout.Label("Time: " + m_AnimTime.ToString("F3"), GUILayout.Width(95)); //do not allow the string to resize the label (and format it to .3 digits) // GUILayout.Space(10); if (GUILayout.Button("Refresh", GUILayout.Width(78))) { RefreshContent(); } EditorGUILayout.EndHorizontal(); GUI.changed = false; bool oldEnabled = GUI.enabled; GUI.enabled = (m_MaxSliderTime > 0); m_AnimTime = GUILayout.HorizontalSlider(m_AnimTime, 0, m_MaxSliderTime, GUILayout.Width(450)); GUI.enabled = oldEnabled; if (GUI.changed) { UpdateAnimationsByTime(m_AnimTime); } //EditorGUILayout.CurveField("Test", testCurve); }
private static void TransformDisplay(int Index, ref Transform T) { GUIEditorUtils.LookLikeInspector(); T = (Transform)EditorGUILayout.ObjectField("Part #" + Index, T, typeof(Transform), true); GUIEditorUtils.LookLikeControls(); }