Exemplo n.º 1
0
 public void DoLayoutList(Action changed = null)
 {
     ScopeChange.Begin();
     if (m_serializedProperty == null)
     {
         if (isExpanded)
         {
             m_lst.DoLayoutList();
         }
         else
         {
             m_lst.DoListHeader(m_lstMethod);
         }
     }
     else
     {
         if (m_serializedProperty.isExpanded)
         {
             m_lst.DoLayoutList();
         }
         else
         {
             m_lst.DoListHeader(m_lstMethod);
         }
     }
     if (ScopeChange.End())
     {
         changed?.Invoke();
     }
 }
Exemplo n.º 2
0
        public static void ChangeAndDirty <T>(UnityObject target, Func <T> chacgeGUI, Action <T> dirtyExec, string undoName = "")
        {
            ScopeChange.Begin();
            var _b = chacgeGUI();

            if (ScopeChange.End())
            {
                Undo.RecordObject(target, $"{target.name} {undoName} Changed");
                dirtyExec.Invoke(_b);
                EditorUtility.SetDirty(target);
            }
        }
Exemplo n.º 3
0
        protected void _ColorField(ref Rect rect, UnityObject obj, Color color, Action <Color> changed)
        {
            rect.width = 32;
            ScopeChange.Begin();
            var _color = UnityEditorEditorGUI.DoColorField(rect, obj.GetInstanceID(), color, true, true, false);

            if (ScopeChange.End())
            {
                EditorHelper.Dirty(obj, () => {
                    changed(_color);
                });
            }
            rect.x += rect.width + 4;
        }
Exemplo n.º 4
0
        protected void _AlphaSlider(ref Rect rect, UnityObject obj, Color color, Action <Color> changed)
        {
            rect.width = 40;

            ScopeChange.Begin();
            var _a = HEditorGUI.Slider(rect, color.a, 0, 1);

            if (ScopeChange.End())
            {
                EditorHelper.Dirty(obj, () => {
                    changed(ColorUtils.RGBA(color, _a));
                });
            }
            rect.x += rect.width + 4;
        }
Exemplo n.º 5
0
        protected void _AlphaSlider(ref Rect rect, UnityObject obj, float alpha, Action <float> changed)
        {
            rect.width = 40;

            ScopeChange.Begin();
            var _a = HEditorGUI.Slider(rect, alpha, 0, 1);

            if (ScopeChange.End())
            {
                EditorHelper.Dirty(obj, () => {
                    changed(_a);
                });
            }
            rect.x += rect.width + 4;
        }
Exemplo n.º 6
0
        protected void _Graphic(ref Rect rect, Graphic obj)
        {
            _ColorField(ref rect, obj, obj.color, (color) => {
                obj.color = color;
            });
            _AlphaSlider(ref rect, obj, obj.color, (color) => {
                obj.color = color;
            });

            rect.width = 16;
            ScopeChange.Begin();
            var _b = EditorGUI.Toggle(rect, obj.raycastTarget);

            if (ScopeChange.End())
            {
                EditorHelper.Dirty(obj, () => {
                    obj.raycastTarget = _b;
                });
            }
        }
Exemplo n.º 7
0
        void DrawSerializeReference(SerializedProperty property)
        {
            var cont = EditorHelper.TempContent(L10n.Tr(property.displayName));
            var rect = GUILayoutUtility.GetRect(cont, EditorStyles.numberField, GUILayout.Height(property.GetPropertyHeight(true)));

            var rectR = EditorGUI.PrefixLabel(rect, cont);

            rectR.height = EditorGUIUtility.singleLineHeight;

            if (m_managedReferenceTypes == null)
            {
                InitSubClass(property);
            }

            ScopeChange.Begin();
            var index = Array.IndexOf(m_managedReferenceFullnames, property.managedReferenceFullTypename);

            index = EditorGUI.Popup(rectR, index, m_managedReferencePopup);
            if (ScopeChange.End())
            {
                property.SetManagedReferenceValue(m_managedReferenceTypes[index]);
            }

            //GUI.Button( rectR , "DrawSerializeReference" );
            //HEditorGUI.DrawDebugRect( rectR );
            ;
            EditorGUI.PropertyField(rect, property, GUIContent.none, true);

            void InitSubClass(SerializedProperty p)
            {
                var lst = AssemblieUtils.SubclassesOf(property.GetManagedReferenceFieldType()).ToList();

                lst.Insert(0, null);
                m_managedReferenceTypes     = lst.ToArray();
                m_managedReferencePopup     = m_managedReferenceTypes.Select(t => t == null ? new GUIContent("None", EditorIcon.warning) : new GUIContent(t.ToString(), EditorIcon.icons_processed_boo_script_icon_asset)).ToArray();
                m_managedReferenceFullnames = m_managedReferenceTypes.Select(t => t == null ? "" : $"{t.Assembly.ToString().Split( ',' )[ 0 ]} {t.FullName}").ToArray();
            }
        }
Exemplo n.º 8
0
        protected void _ObjectField <T>(ref Rect rect, T obj, Action <T> changed) where T : UnityObject
        {
            if (objectField == null)
            {
                objectField              = new GUIStyle(EditorStyles.objectField);
                objectField.padding.top  = 1;
                objectField.padding.left = 2;
            }
            rect.width = 33;
            ScopeChange.Begin();
            var id = go.GetInstanceID();
            var t  = obj != null?obj.GetType() : typeof(T);

            var _obj = UnityEditorEditorGUI.DoObjectField(rect, rect, id, obj, t, null, null, false, objectField);

            if (ScopeChange.End())
            {
                EditorHelper.Dirty(go, () => {
                    changed((T)_obj);
                });
            }
            rect.x += rect.width + 4;
        }
Exemplo n.º 9
0
        /////////////////////////////////////////
        public void DrawItem()
        {
            if (currentItem == null)
            {
                return;
            }
            if (currentItem.folder)
            {
                return;
            }

            using (new GUILayoutScope(16, 4)) {
                ////////////////////////

                ScopeHorizontal.Begin();
                EditorGUILayout.LabelField("General", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                ScopeHorizontal.End();

                ScopeVertical.Begin(GUI.skin.box);
                ScopeChange.Begin();
                currentItem.m_json.autoReferenced = EditorGUILayout.Toggle("Auto Referenced", currentItem.m_json.autoReferenced);
                if (ScopeChange.End())
                {
                    currentItem.isDIRTY = true;
                }
                ScopeVertical.End();

                ////////////////////////

                ScopeHorizontal.Begin();
                EditorGUILayout.LabelField("Assembly Definition References", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                ScopeHorizontal.End();

                ////////////////////////

                Ref del = null;

                foreach (var e in currentItem.参照しているasmdefのリスト)
                {
                    using (new GUIBackgroundColorScope()) {
                        if (e.guid.IsEmpty())
                        {
                            if (e.バックアップされている)
                            {
                                GUI.backgroundColor = Color.yellow;
                            }
                            else
                            {
                                GUI.backgroundColor = Color.red;
                            }
                        }
                        ScopeHorizontal.Begin(EditorStyles.helpBox);
                        ScopeChange.Begin();
                        e.toggle = HEditorGUILayout.ToggleLeft(e.asmDefの名前, e.toggle);
                        if (ScopeChange.End())
                        {
                            currentItem.isDIRTY = true;
                        }
                        GUILayout.FlexibleSpace();
                        if (HEditorGUILayout.IconButton(EditorIcon.minus))
                        {
                            del = e;
                            currentItem.isDIRTY = true;
                        }

                        ScopeHorizontal.End();
                    }
                }
                if (del != null)
                {
                    currentItem.参照しているasmdefのリスト.Remove(del);
                }

                //ScopeHorizontal.Begin();
                //GUILayout.FlexibleSpace();
                //if( GUILayout.Button( "整形") ) {
                //	Debug.Log( currentItem.m_json.name );
                //	ShellUtils.Start( "dotnet-format", $"-v diag {currentItem.m_json.name}.csproj" );
                //	//ShellUtils.Start( "cmd.exe", "/k dir" );
                //	//System.Diagnostics.Process p = new System.Diagnostics.Process();
                //	//p.StartInfo.FileName = "cmd.exe";
                //	//p.StartInfo.Arguments = "/k dotnet-format -v diag com.unity.cinemachine.Editor.csproj";
                //	//p.SynchronizingObject = this;
                //	//p.StartInfo.UseShellExecute = true;
                //	//p.Exited += ( sender, e ) => {
                //	//	EditorApplication.delayCall += () => {
                //	//		exitHandler( sender, e );
                //	//	};
                //	//};
                //	//p.Start();
                //	//p.WaitForExit();
                //}
                //ScopeHorizontal.End();

                GUILayout.FlexibleSpace();
            }


            var dropRc = GUILayoutUtility.GetLastRect();

            DrawFileDragArea(dropRc, DD, DragAndDropVisualMode.Link);
            //HEditorGUI.DrawDebugRect( dropRc );
        }