Beispiel #1
0
        public static bool IconButton(Rect position, GUIContent content, GUIStyle style, float heighOffset = 0, bool mouseUp = false)
        {
            bool result = false;

            position.y         += heighOffset;
            HEditorGUI.lastRect = position;
            if (!mouseUp && EditorHelper.HasMouseClick(position))
            {
                Event.current.Use();
                result = true;
            }
            //else if( EditorHelper.HasMouseClick( position, EventMouseButton.R ) ) {
            //	//Event.current.Use();
            //	result = true;
            //}
            if (!mouseUp)
            {
                GUI.Button(position, content, style);
                return(result);
            }
            // ドッキングボタンの対応
            // MouseUpでボタン押したことにする
            GUI.changed = false;
            result      = GUI.Button(position, content, style);
            GUI.changed = result;
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// ツールバー部の描画を行います
        /// </summary>
        void DrawToolBar()
        {
            Rect r = new Rect(1, 45, EditorGUIUtility.currentViewWidth - 3, 18);              // GUILayoutUtility.GetRect( new GUIContent( "" ), "toolbarbutton" );

            using (new GUILayout.AreaScope(r)) {
                using (new GUILayout.HorizontalScope(EditorStyles.toolbar)) {
                    GUILayout.Label(EditorGUIUtility.IconContent("_Popup"), EditorStyles.toolbarButton);
                    if (EditorHelper.HasMouseClick(GUILayoutUtility.GetLastRect()))
                    {
                        var optionsMenu = new GenericMenu();
                        //optionsMenu.AddItem( new GUIContent( "Create SubAsset AnimationClip" ), false, Toolbar_CreateSubAssetAnimationClip );
                        optionsMenu.AddItem(new GUIContent("Add Motion FBXs"), false, Toolbar_AddMotionFBXs);
                        optionsMenu.AddItem(new GUIContent("Clear All State"), false, Toolbar_AllStateClear);
                        optionsMenu.AddItem(new GUIContent("Export Enum"), false, Toolbar_ExportDefine);
                        optionsMenu.AddItem(new GUIContent("Sort State"), false, Toolbar_StateSort);

                        optionsMenu.DropDown(GUILayoutUtility.GetLastRect());
                    }

                    GUILayout.FlexibleSpace();

                    //GUILayout.Label( "num: " + self.layers[ 0 ].stateMachine.states.Length, EditorStyles.toolbar );
                }
            }
        }
        /////////////////////////////////////////
        protected override void OnRowGUI(Item item, RowGUIArgs args)
        {
            if (item.missingなasmdefを検知)
            {
                EditorGUI.DrawRect(args.rowRect, ColorUtils.RGBA(Color.red, 0.2f));
            }
            DefaultRowGUI(args);

            var rc2 = args.rowRect.W(16);

            rc2.x += (16 * (item.depth + 1));
            rc2    = rc2.AlignCenter(14, 14);

            if (EditorHelper.HasMouseClick(rc2))
            {
                EditorApplication.delayCall += () => { EditorHelper.PingAndSelectObject(item.target); };
            }

            if (item.isDIRTY)
            {
                GUI.DrawTexture(args.rowRect.W(16), EditorIcon.warning);
            }
            if (item.isGUID)
            {
                HEditorGUI.MiniLabelR(args.rowRect, "GUID");
            }
        }
        public static bool ToggleBox(bool value, GUIContent content, params GUILayoutOption[] options)
        {
            var position = GUILayoutUtility.GetRect(content, toggleBox, options);
            var result   = EditorHelper.HasMouseClick(position);

            var backgroundColor = GUI.backgroundColor;

            //if( value ) {
            //	GUI.backgroundColor = ColorUtils.RGB( 169, 201, 255 );
            //}

            //if( value )
            //	EditorGUI.DrawRect( position, Color.white );
            using (new GUIBackgroundColorScope()) {
                if (value)
                {
                    //GUI.backgroundColor = ColorUtils.RGB( 169, 201, 255 );
                    var r = position;
                    r.x     += 1;
                    r.width -= 2;
                    EditorGUI.DrawRect(r, EditorGUIUtility.isProSkin ? ColorUtils.RGB(128, 128, 128) : Color.white);
                    //GUI.backgroundColor = ColorUtils.RGB( 200, 200, 200 );
                }
                var b = GUI.Toggle(position, value, content, toggleBox);

                return(result);
            }
        }
Beispiel #5
0
        public static bool ClickableIcon(Rect position, Texture2D image, float alpha = 1.0f)
        {
            bool result = false;

            HEditorGUI.lastRect = position;

            GUI.DrawTexture(position, image, ScaleMode.StretchToFill, true, 0, new Color(1, 1, 1, alpha), 0, 0);
            if (EditorHelper.HasMouseClick(position))
            {
                result = true;
            }
            return(result);
        }
Beispiel #6
0
        public static bool ImageButton(Rect position, GUIContent content, GUIStyle style)
        {
            bool result = false;

            //position.y += heighOffset;
            if (EditorHelper.HasMouseClick(position))
            {
                Event.current.Use();
                result = true;
            }
            GUI.Button(position, content, style);
            return(result);
        }
Beispiel #7
0
		bool ClickMenu( string label ) {
			if( Event.current.type == EventType.Repaint || Event.current.type == EventType.MouseDown ) {
				var r = GUILayoutUtility.GetLastRect();
				var v2 = EditorStyles.label.CalcSize( EditorHelper.TempContent( label ) );
				r.width = v2.x;
				r.height = v2.y;
				//GUI.Box( r, "", (GUIStyle) "SelectionRect" );
				if( EditorHelper.HasMouseClick( r, EventMouseButton.M ) ) {
					return true;
				}
			}
			return false;
		}
Beispiel #8
0
        protected virtual void ShowButton(Rect r)
        {
            var rb = r;

            rb.x += (17 * 3);
            //HEditorGUI.DrawDebugRect( rb );
            if (EditorHelper.HasMouseClick(rb))
            {
                OnClose();
            }

            if (!E.i.m_windowShade)
            {
                return;
            }
            if (m_disableShadeMode)
            {
                return;
            }
            var a = (Texture2D)EditorIcon.icons_processed_unityengine_ui_aspectratiofitter_icon_asset;

            if (showMode == 4)
            {
                return;
            }
            //}

            if (HEditorGUI.IconButton(r, a))
            {
                //var dockArea = _editorWindow.dockArea;

                if (position.height < 25)
                {
                    var rr = position;
                    rr.height = m_height + 21;
                    m_self.containerWindow.SetProperty <Rect>("position", rr);
                }
                else
                {
                    minSize = new Vector2(minSize.x, -10);
                    var rr = position;
                    m_height  = rr.height;
                    rr.height = 21;

                    m_self.containerWindow.SetProperty <Rect>("position", rr);
                }
                m_shade = !m_shade;
                //Debug.Log( m_shade );
            }
        }
Beispiel #9
0
        public static bool DropDown(GUIContent content, Action action, params GUILayoutOption[] options)
        {
            var size = EditorStyles.toolbarDropDown.CalcSize(EditorHelper.TempContent(content.text));
            var r    = GUILayoutUtility.GetRect(content, toolbarDropDown, options.Length == 0 ? new GUILayoutOption[] { GUILayout.Width(size.x + 16) } : options);

            HEditorGUI.lastRect = r;
            var result = EditorHelper.HasMouseClick(r);

            if (result)
            {
                action?.Invoke();
                Event.current.Use();                //ボタンがアクティブになるため
            }
            GUI.Button(r, content, toolbarDropDown);
            return(result);
        }
Beispiel #10
0
 /// <summary>
 /// ラベルクリックの判定を行います
 /// </summary>
 /// <param name="label"></param>
 /// <param name="prop"></param>
 /// <returns></returns>
 bool IsLabelClick(GUIContent label, SerializedProperty prop)
 {
     if (Event.current.type == EventType.Repaint || Event.current.type == EventType.MouseDown)
     {
         var r  = GUILayoutUtility.GetLastRect();
         var v2 = EditorStyles.label.CalcSize(label);
         r.width  = v2.x;
         r.height = v2.y;
         //GUI.Box( r, "", (GUIStyle) "SelectionRect" );
         if (EditorHelper.HasMouseClick(r, EventMouseButton.M))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #11
0
		/// <summary>
		/// 
		/// </summary>
		bool DrawTitleToolIcon( Rect rc ) {
			Rect rc2 = rc;
			float yy = rc2.y;
			rc2.x = EditorGUIUtility.currentViewWidth - 18;
			rc2.y = yy - 1;
			rc2.width = 16;
			rc2.height = 18;
			GUI.Label( rc2, EditorGUIUtility.IconContent( "_Popup" ), GUIStyle.none );
			if( EditorHelper.HasMouseClick( rc2 ) ) {
				On_Popup();
				return true;
			}

			rc2.x -= 20;
			rc2.y = yy - 4;
			GUI.Label( rc2, EditorGUIUtility.IconContent( "Animator Icon" ), GUIStyle.none );
			if( EditorHelper.HasMouseClick( rc2 ) ) {
				On_Animator_Icon();
				return true;
			}

			rc2.x -= 20;
			rc2.width = 16;
			rc2.y = yy - 2;
			GUI.Label( rc2, EditorGUIUtility.IconContent( "Animation Icon" ), GUIStyle.none );
			if( EditorHelper.HasMouseClick( rc2 ) ) {
				On_Animation_Icon();
				return true;
			}

			rc2.x -= 20;
			rc2.y = yy - 3;
			GUI.Label( rc2, EditorGUIUtility.IconContent( "AnimatorController Icon" ), GUIStyle.none );
			if( EditorHelper.HasMouseClick( rc2 ) ) {
				On_AnimatorController_Icon();
				return true;
			}

			rc2.x -= 20;
			GUI.Label( rc2, EditorGUIUtility.IconContent( "cs Script Icon" ), GUIStyle.none );
			if( EditorHelper.HasMouseClick( rc2 ) ) {
				On_cs_Script_Icon();
				return true;
			}

			return false;
		}
Beispiel #12
0
        public static Vector3 Vector3Field(Rect position, GUIContent content, Vector3 _value, params GUILayoutOption[] options)
        {
            var r = EditorGUI.PrefixLabel(position, content);

            //EditorGUI.DrawRect( , Color.black );
            if (EditorHelper.HasMouseClick(position.W(r.x - EditorGUI.indentLevel * 16), EventMouseButton.R))
            {
                var m = new GenericMenu();
                m.AddItem(SharedModule.S._Copy, (context) => EditorHelper.MenuCopyPos((Vector3)context), _value);
                //m.AddItem( SharedModule.S._Paste, ( context ) => {
                //	//ref Vector3 = (ref Vector3)context;
                //	_value = EditorHelper.GetMenuPastePos();
                //} );
                m.DropDownPopupRect(position);
            }
            return(EditorGUI.Vector3Field(r, "", _value));
        }
Beispiel #13
0
        public override void OnGUI(Rect rc, SerializedProperty property, GUIContent label)
        {
            SceneAsset scn   = null;
            var        _guid = property.FindPropertyRelative("guid");
            var        _name = property.FindPropertyRelative("name");

            if (!string.IsNullOrEmpty(_guid.stringValue))
            {
                scn = AssetDatabase.LoadAssetAtPath <SceneAsset>(AssetDatabase.GUIDToAssetPath(_guid.stringValue));
            }
            var rcField = EditorGUI.PrefixLabel(rc, GUIUtility.GetControlID(FocusType.Passive), label);
            var rcLabel = rc;
            var size    = EditorStyles.label.CalcSize(label);

            rcLabel.width = size.x;
            //GUI.Box( rcLabel, "", (GUIStyle) "SelectionRect" );

            if (EditorHelper.HasMouseClick(rcLabel))
            {
                var menu = new GenericMenu();
                foreach (var s in getBuildSceneName())
                {
                    menu.AddItem(new GUIContent(Path.GetFileNameWithoutExtension(s)), false, (userData) => {
                        property.serializedObject.Update();

                        string ss         = (string)userData;
                        _name.stringValue = Path.GetFileNameWithoutExtension(ss);
                        var gu            = GetGUID(s);
                        _guid.stringValue = gu;

                        property.serializedObject.ApplyModifiedProperties();
                    }, s);
                }
                menu.ShowAsContext();
            }

            GUI.changed = false;
            SceneAsset value = (SceneAsset)EditorGUI.ObjectField(rcField, scn, typeof(SceneAsset), false);

            if (GUI.changed)
            {
                _name.stringValue = value.name;
                var ss = AssetDatabase.GetAssetPath(value);
                _guid.stringValue = Path.GetFileNameWithoutExtension(AssetDatabase.AssetPathToGUID(ss));
            }
        }
Beispiel #14
0
        public static bool DropDown(GUIContent content, params GUILayoutOption[] options)
        {
            if (ToolbarDropDown == null)
            {
                return(false);
            }

            var r      = GUILayoutUtility.GetRect(content, ToolbarDropDown, options);
            var result = EditorHelper.HasMouseClick(r);

            if (result)
            {
                Event.current.Use();
            }
            GUI.Button(r, content, ToolbarDropDown);
            return(result);
        }
Beispiel #15
0
        public static bool ToggleDropDown2(bool toggle, GUIContent content, Action buttonAction, Action allowAction, params GUILayoutOption[] options)
        {
            Vector2 size;

            if (content.text.IsEmpty())
            {
                size = new Vector2(28, EditorGUIUtility.singleLineHeight);
            }
            else
            {
                size = EditorStyles.toolbarDropDown.CalcSize(EditorHelper.TempContent(content.text));
            }
            var r = GUILayoutUtility.GetRect(content, toolbarDropDown, options.Length == 0 ? new GUILayoutOption[] { GUILayout.Width(size.x + 16) } : options);

            HEditorGUI.lastRect = r;

            var lRect = r;

            lRect.width = 18;
            lRect.x    += r.width;
            lRect.x    -= lRect.width;
            if (EditorHelper.HasMouseClick(lRect))
            {
                allowAction?.Invoke();
                Event.current.Use();
            }
            var result = EditorHelper.HasMouseClick(r);

            if (result)
            {
                buttonAction?.Invoke();
                Event.current.Use();                //ボタンがアクティブになるため
            }
            GUI.Toggle(r, toggle, content, toolbarDropDown);

            if (UnitySymbol.UNITY_2019_3_OR_NEWER)
            {
                var rr = lRect.AlignCenter(12, 12);
                GUI.DrawTexture(rr, SharedModule.Icon.icondropdown_, ScaleMode.ScaleToFit);
                GUI.Label(lRect.AddH(-3), GUIContent.none, HEditorStyles.dopesheetBackground);
            }
            //EditorGUI.DrawRect( lRect , new Color(0,0,1,0.2f));
            return(result);
        }
Beispiel #16
0
        public static bool Toggle(Rect position, bool value, GUIContent content, GUIStyle style)
        {
            //bool ret=false;
            //bool ret2 = false;
            //if( Event.current.type == EventType.MouseDown ) {
            //	ret2 = true;
            //}
            var result = EditorHelper.HasMouseClick(position);

            if (GUI.Toggle(position, value, content, style))
            {
                //ret= true;
                //Debug.Log( Event.current.type );
            }
            //if( Event.current.type != EventType.Used ) {
            //	return false;
            //}
            return(result);
        }
Beispiel #17
0
        public static bool DropDown(Rect position, GUIContent content, GUIStyle style, float allowWidth, Action buttonAction, Action allowAction)
        {
            lastRect       = position;
            lastRect.width = allowWidth;
            lastRect.x    += position.width;
            lastRect.x    -= lastRect.width;
            if (EditorHelper.HasMouseClick(lastRect))
            {
                allowAction?.Invoke();
                Event.current.Use();
            }
            if (GUI.Button(position, content, style))
            {
                buttonAction?.Invoke();
            }

            //EditorGUI.DrawRect( lastRect, new Color( 0, 0, 1, 0.5f ) );
            return(false);
        }
Beispiel #18
0
 public static bool StaticButton(GUIContent content, params GUILayoutOption[] options)
 {
     if (Toolbarbutton2 == null)
     {
         return(false);
     }
     try
     {
         GUILayout.Label(content, Toolbarbutton2, options);
         if (EditorHelper.HasMouseClick(GUILayoutUtility.GetLastRect()))
         {
             return(true);
         }
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(false);
 }
Beispiel #19
0
        public static bool IconButton(Rect position, Texture2D tex, GUIStyle style, float heighOffset = 0)
        {
            bool result = false;

            position.y += heighOffset;
            if (EditorHelper.HasMouseClick(position))
            {
                Event.current.Use();
                result = true;
            }
            //EditorGUI.DrawRect( r2, new Color( 0, 0, 1, 0.2f ) );
            //GUIStyle s = EditorStyles.label;
            //s.name = "IconButton";
            ////s.name = "Command";
            //var a = R.Field( "blockId", "UnityEngine.GUIStyle", "UnityEngine.dll" );
            ////var mm = a.GetValue( s );
            //a.SetValue( s , 0);
            //EditorGUI.DrawRect( position, new Color( 0, 0, 1, 0.2f ) );
            GUI.Button(position, EditorHelper.TempContent(tex), style);
            return(result);
        }
Beispiel #20
0
        public static bool DropDown(Rect position, GUIContent content, GUIStyle style, float allowWidth, Action buttonAction, Action allowAction)
        {
            lastRect       = position;
            lastRect.width = allowWidth;
            lastRect.x    += position.width;
            lastRect.x    -= lastRect.width;
            if (EditorHelper.HasMouseClick(lastRect))
            {
                allowAction?.Invoke();
                Event.current.Use();
            }
            if (GUI.Button(position, content, style))
            {
                buttonAction?.Invoke();
            }

            var rr = lastRect.AlignCenter(12, 12);

            //rr.y -= 1;
            GUI.DrawTexture(rr, SharedModule.Icon.icondropdown_, ScaleMode.ScaleToFit);
            //EditorGUI.DrawRect( lastRect, new Color( 0, 0, 1, 0.5f ) );
            return(false);
        }
Beispiel #21
0
        /// <summary>
        ///
        /// </summary>
        void OnDrawGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            GUILayout.Label(EditorGUIUtility.IconContent("_Popup"), EditorStyles.toolbarButton, GUILayout.Width(27));
            if (EditorHelper.HasMouseClick(GUILayoutUtility.GetLastRect()))
            {
                var window = EditorWindow.GetWindow <ObjectBrowserPreference>(true);
                window.SetTitle(new GUIContent("Preference"));
                window.m_parentWindow = this;
            }

            GUILayout.Label(m_contentTypeList[m_selectTypeList], m_style.ToolbarPopup, GUILayout.Width(160));
            if (EditorHelper.HasMouseClick(GUILayoutUtility.GetLastRect()))
            {
                EditorUtility.DisplayCustomMenu(
                    EditorHelper.PopupRect(GUILayoutUtility.GetLastRect()),
                    m_contentTypeList,
                    -1,
                    selectMenuItemFunction,
                    Selection.objects);
            }

            var _b = GUILayout.Toggle(m_hideFlag, "hideFlags", m_style.toolbarbutton, GUILayout.Width(80));

            if (_b != m_hideFlag)
            {
                m_hideFlag = _b;
                onButton_SearchStart();
            }


            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            GUIStyle styleListElement = new GUIStyle("PreferencesKeysElement");


            bool _select = false;

            if (m_objList != null)
            {
                m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos);

                m_objList = m_objList.Where(x => x != null).ToArray();

                for (int i = 0; i < m_objList.Length; ++i)
                {
                    var obj = m_objList[i];
                    var r   = GUILayoutUtility.GetRect(position.width + 1, styleListElement.fixedHeight);

                    if (EditorHelper.HasMouseClick(r))
                    {
                        //Debug.LogFormat( "hit {0}: {1}: {2}", obj.name, r, m_ScrollPos );
                        m_selectObjIndex = i;

                        _select = true;
                        Repaint();
                    }
                    var col = styleListElement.normal.textColor;
                    if (m_selectObjIndex == i)
                    {
                        styleListElement.normal.background = styleListElement.onNormal.background;
                        styleListElement.normal.textColor  = styleListElement.onNormal.textColor;
                    }
                    else
                    {
                        styleListElement.normal.background = null;
                    }

                    if (obj != null)
                    {
                        var rofs = r;
                        GUI.Label(r, "", styleListElement);
                        drawBackColor(r, 0x00);
                        rofs.x += 16;
                        GUI.Label(rofs, obj.name, styleListElement);

                        if (AssetDatabase.GetAssetOrScenePath(obj).Contains(".unity"))
                        {
                            rofs.x    -= 16;
                            rofs.width = 16;
                            GUI.Label(rofs, "S", styleListElement);
                        }
                    }

                    styleListElement.normal.textColor = col;
                }

                EditorGUILayout.EndScrollView();
            }

            if (_select)
            {
                forcusObject(m_selectObjIndex);

                //Selection.activeObject.hideFlags = HideFlags.None;
            }
        }
Beispiel #22
0
        protected virtual void ShowButton(Rect r)
        {
            var rb = r;

            rb.x += (17 * 3);
            //HEditorGUI.DrawDebugRect(rb);
            if (EditorHelper.HasMouseClick(rb))
            {
                OnClose();
            }

            if (!E.i.m_windowShade)
            {
                return;
            }
            if (m_disableShadeMode)
            {
                return;
            }
            var a = (Texture2D)EditorIcon.icons_processed_unityengine_ui_aspectratiofitter_icon_asset;

            if (_editorWindow == null)
            {
                return;
            }
            //if( _editorWindow.dockArea != null ) {
            if (_editorWindow.showMode == 4)
            {
                return;
            }
            //}

            if (HEditorGUI.IconButton(r, a))
            {
                //Debug.Log( $"{position}" );
                var dockArea = _editorWindow.dockArea;
                //if( dockArea != null ) {
                //	var wnd = dockArea.GetProperty<object>( "window" );

                //	var inaa = wnd.GetField<int>( "m_ShowMode" );
                //	Debug.Log( inaa );
                //}

                if (position.height < 25)
                {
                    var rr = position;
                    rr.height = m_height;


                    //if( dockArea == null ) Debug.Log( "dockArea null" );


                    if (dockArea != null)
                    {
                        var wnd = dockArea.GetProperty <object>("window");
                        var rrc = wnd.GetProperty <Rect>("position");
                        //Debug.Log( rrc );
                        wnd.SetProperty <Rect>("position", rr);
                    }

                    //position = rr;
                }
                else
                {
                    minSize = new Vector2(minSize.x, -10);
                    var rr = position;
                    m_height  = rr.height;
                    rr.height = 21;

                    //var dockArea = _editorWindow.dockArea;
                    //if( dockArea == null ) Debug.Log( "dockArea null" );
                    if (dockArea != null)
                    {
                        var wnd = dockArea.GetProperty <object>("window");
                        wnd.SetProperty <Rect>("position", rr);
                    }

                    //position = rr;
                }
                m_shade = !m_shade;
                //Debug.Log( m_shade );
            }
        }