Пример #1
0
 internal DirectoryLabelSetting(DirectoryLabelSetting copy)
 {
     DirectoryName   = copy.DirectoryName;
     AssetBundleName = copy.AssetBundleName;
     Type            = copy.Type;
     IsActive        = copy.IsActive;
 }
        private void LabelSettingDrawer(DirectoryLabelSetting setting)
        {
            var rect = EditorGUILayout.BeginVertical(GUIHelper.Styles.NoSpaceBox);

            {
                GUI.backgroundColor = setting.IsActive ? Color.green : Color.grey;
                if (GUILayout.Button("", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)))
                {
                    UndoHelper.BuilderDataUndo("Change DirectoryLabel activation");
                    setting.IsActive = !setting.IsActive;
                    EditorGUIUtility.keyboardControl = 0;
                }
                GUI.backgroundColor = Color.white;

                EditorGUILayout.BeginHorizontal();
                {
                    Undo.IncrementCurrentGroup();
                    UndoHelper.BuilderDataUndo("Change DirectoryLabel Setting");
                    GUILayout.Label("Directory", GUILayout.Width(70));
                    setting.DirectoryName = EditorGUILayout.TextField(setting.DirectoryName);
                    var path = FileHelper.GetDraggedObject(Event.current, GUILayoutUtility.GetLastRect());
                    if (!string.IsNullOrEmpty(path))
                    {
                        setting.DirectoryName = FileHelper.AssetPathToBuildPath(BuildRootPath, path);
                    }
                }
                EditorGUILayout.EndHorizontal();

                if (setting.IsActive)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        Undo.IncrementCurrentGroup();
                        UndoHelper.BuilderDataUndo("Change DirectoryLabel Setting");
                        GUILayout.Label("Label", GUILayout.Width(70));
                        setting.AssetBundleName = EditorGUILayout.TextField(setting.AssetBundleName);
                    }
                    EditorGUILayout.EndHorizontal();

                    setting.Type = ( DirectoryLabelNameType )EditorGUILayout.EnumPopup(setting.Type);
                    GUILayout.Space(5);
                }
            }
            EditorGUILayout.EndVertical();

            GUILayout.Space(3);

            if (IsContextClick(Event.current, rect))
            {
                var menu = new GenericMenu();
                menu.AddItem(new GUIContent("Delete"), false, () => {
                    UndoHelper.BuilderDataUndo("Delete DirectoryLabel Setting");
                    LabelSetting.Remove(setting);
                });
                menu.ShowAsContext();
            }
        }