Exemplo n.º 1
0
            public static void OpenAsName(string assetPath)
            {
                var t = EditorHelper.GetTypeFromString("HananokiEditor.AsmdefEditorWindow");

                t.MethodInvoke("OpenAsName", new Type[] { typeof(string) }, new object[] { assetPath });
            }
Exemplo n.º 2
0
 protected void Label(RowGUIArgs args, Rect rect, string text, Texture2D image, GUIStyle style)
 {
     _Label(rect, EditorHelper.TempContent(text, image), style, args);
 }
Exemplo n.º 3
0
            public static void OpenAsName(UnityObject unityObject)
            {
                var t = EditorHelper.GetTypeFromString("HananokiEditor.AsmdefEditorWindow");

                t.MethodInvoke("OpenAsName", new Type[] { typeof(UnityObject) }, new object[] { unityObject });
            }
Exemplo n.º 4
0
 public static GUIContent contentTemp(this string s)
 {
     return(EditorHelper.TempContent(s, s));
 }
Exemplo n.º 5
0
 protected void Label(RowGUIArgs args, Rect rect, string text)
 {
     Label(rect, EditorHelper.TempContent(text), args);
 }
Exemplo n.º 6
0
 public static bool StaticButton(Texture image, params GUILayoutOption[] options)
 {
     return(StaticButton(EditorHelper.TempContent(image), GUILayout.Width(26)));
 }
Exemplo n.º 7
0
 public static Rect PopupRect(this Rect r)
 {
     return(EditorHelper.PopupRect(r));
 }
Exemplo n.º 8
0
 public static bool Button(string s, Texture image, params GUILayoutOption[] options)
 {
     return(Button(EditorHelper.TempContent(s, image), options));
 }
Exemplo n.º 9
0
 public static bool StaticButton(string s, params GUILayoutOption[] options)
 {
     return(StaticButton(EditorHelper.TempContent(s), options));
 }
Exemplo n.º 10
0
 public static bool DropDown(Rect position, string text, GUIStyle style, float allowWidth, Action buttonAction, Action allowAction)
 {
     return(DropDown(position, EditorHelper.TempContent(text), style, allowWidth, buttonAction, allowAction));
 }
Exemplo n.º 11
0
 public static bool DropDown(string s, params GUILayoutOption[] options)
 {
     return(DropDown(EditorHelper.TempContent(s), options));
 }
Exemplo n.º 12
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 );
            }
        }
Exemplo n.º 13
0
        public void Create(SerializedObject serializedObject, string propertyName, int heightNum = 1, string headerName = "", bool drawer = false)
        {
            m_serializedObject   = serializedObject;
            m_serializedProperty = serializedObject.FindProperty(propertyName);
            m_headerName         = headerName;
            m_lst       = new ReorderableList(serializedObject, m_serializedProperty);
            m_lstMethod = new UnityEditorInternalReorderableList(m_lst);


            if (drawer)
            {
                m_lst.drawElementCallback = (rect, index, isActive, isFocused) => {
                    var rc1 = rect;
                    rc1.y     += 1;
                    rc1.height = EditorGUIUtility.singleLineHeight;
                    EditorGUI.PropertyField(rc1, serializedObject.FindProperty(propertyName + ".Array.data[" + index + "]"));
                };
            }
            else
            {
                m_lst.drawElementCallback = (rect, index, isActive, isFocused) => {
                    var rc1 = rect;
                    rc1.y     += 1;
                    rc1.height = EditorGUIUtility.singleLineHeight;
                    var prop = serializedObject.FindProperty(propertyName + ".Array.data[" + index + "]");

                    var hander = new PropertyHandler(ScriptAttributeUtility.GetHandler(prop));

                    try {
                        if (hander.hasPropertyDrawer)
                        {
                            //m_lst.elementHeightCallback = (index2) => {
                            //	var prop2 = serializedObject.FindProperty( propertyName + ".Array.data[" + index2 + "]" );
                            //	var hander2 = UnityScriptAttributeUtility.GetHandler( prop2 );
                            //	return hander2.GetProperty<PropertyDrawer>( "propertyDrawer" ).GetPropertyHeight( prop2, EditorHelper.TempContent( prop2.displayName ) );
                            //};
                            //	m_lst.elementHeight = hander.GetProperty<PropertyDrawer>( "propertyDrawer" ).GetPropertyHeight( prop, EditorHelper.TempContent( prop.displayName ) );
                            EditorGUI.PropertyField(rc1, prop);
                        }
                        else if (prop != null)
                        {
                            if (prop.propertyType == SerializedPropertyType.Generic)
                            {
                                prop.Next(true);
                                int ii    = 0;
                                int depth = prop.depth;

                                do
                                {
                                    EditorGUI.PropertyField(rc1, prop);

                                    rc1.y += EditorGUIUtility.singleLineHeight;
                                    //if( prop.propertyType == SerializedPropertyType.Vector3 ) {
                                    //	rc1.y += EditorGUIUtility.singleLineHeight;
                                    //	ii++;
                                    //}
                                    ii++;
                                    if (prop.Next(false) == false)
                                    {
                                        break;
                                    }
                                } while(depth == prop.depth);

                                m_lst.elementHeight = (EditorGUIUtility.singleLineHeight * ii) + 4;
                            }
                            else
                            {
                                var cont = EditorHelper.TempContent($"0x{index:X02}:");
                                var size = EditorStyles.label.CalcSize(cont);
                                rc1.width = 40;
                                EditorGUI.LabelField(rc1, cont);
                                var rc2 = rect;
                                rc2.x      = rc1.xMax;
                                rc2.width  = rect.width - 40;
                                rc2.y     += 1;
                                rc2.height = EditorGUIUtility.singleLineHeight;
                                EditorGUI.PropertyField(rc2, prop, GUIContent.none);
                            }
                        }
                    }
                    catch (NullReferenceException e) {
                        Debug.LogException(e);
                    }
                    //if( !prop.hasChildren ) {
                    //	return;
                    //}
                    //prop.Next( true );
                    //int ii = 0;
                    //int depth = prop.depth;
                    //do {
                    //	EditorGUI.PropertyField( rc1, prop );
                    //	rc1.y += EditorGUIUtility.singleLineHeight;
                    //	ii++;
                    //	prop.Next( false );
                    //} while( depth == prop.depth );
                    //m_lst.elementHeight = ( EditorGUIUtility.singleLineHeight * ii ) + 4;
                };
            }
            m_lst.drawHeaderCallback = (rect) => {
                var rc1 = rect;
                rc1.x += 10;

                string title;
                if (m_headerName.IsEmpty())
                {
                    title = $"{m_serializedProperty.displayName}";
                }
                else
                {
                    title = m_headerName;
                }

                if (!m_serializedProperty.isExpanded)
                {
                    title = $"{title}  [{m_serializedProperty.arraySize}]";
                }

                m_serializedProperty.isExpanded = EditorGUI.Foldout(rc1, m_serializedProperty.isExpanded, title);
            };
            m_lst.elementHeight = (EditorGUIUtility.singleLineHeight * heightNum) + 4;
        }
Exemplo n.º 14
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;
            }
        }