Exemplo n.º 1
0
            void ReloadMarkedList()
            {
                mMarkedPathList.Clear();

                AssetDatabase.GetAllAssetBundleNames()
                .SelectMany(n =>
                {
                    var result = AssetDatabase.GetAssetPathsFromAssetBundle(n);

                    return(result.Select(r =>
                    {
                        if (ResKitAssetsMenu.Marked(r))
                        {
                            return r;
                        }

                        if (ResKitAssetsMenu.Marked(r.GetPathParentFolder()))
                        {
                            return r.GetPathParentFolder();
                        }

                        return null;
                    }).Where(r => r != null)
                           .Distinct());
                })
                .ForEach(n => new HorizontalLayout()
                         .AddChild(EasyIMGUI.Label().Text(n))
                         .AddChild(EasyIMGUI.Button()
                                   .Text(LocaleText.Select)
                                   .OnClick(() =>
                {
                    Selection.objects = new[]
                    {
                        AssetDatabase.LoadAssetAtPath <Object>(n)
                    };
                }).Width(50))
                         .AddChild(EasyIMGUI.Button()
                                   .Text(LocaleText.CancelMark)
                                   .OnClick(() =>
                {
                    ResKitAssetsMenu.MarkAB(n);

                    EditorLifecycle.PushCommand(() => { ReloadMarkedList(); });
                }).Width(75))
                         .Parent(mMarkedPathList)
                         );
            }
Exemplo n.º 2
0
            void ReloadMarkedList()
            {
                mMarkedPathList.Clear();

                AssetDatabase.GetAllAssetBundleNames()
                .SelectMany(n =>
                {
                    var result = AssetDatabase.GetAssetPathsFromAssetBundle(n);

                    return(result.Select(r =>
                    {
                        if (ResKitAssetsMenu.Marked(r))
                        {
                            return r;
                        }

                        if (ResKitAssetsMenu.Marked(r.GetPathParentFolder()))
                        {
                            return r.GetPathParentFolder();
                        }

                        return null;
                    }).Where(r => r != null)
                           .Distinct());
                })
                .ForEach(n => new HorizontalLayout()
                         .AddChild(new LabelView(n))
                         .AddChild(new ButtonView("选择", () =>
                {
                    Selection.objects = new[]
                    {
                        AssetDatabase.LoadAssetAtPath <Object>(n)
                    };
                }).Width(50))
                         .AddChild(new ButtonView("取消标记", () =>
                {
                    ResKitAssetsMenu.MarkAB(n);

                    EditorLifecycle.PushCommand(() => { ReloadMarkedList(); });
                }).Width(75))
                         .AddTo(mMarkedPathList)
                         );
            }
Exemplo n.º 3
0
        public void OnCreateUIPanelClick()
        {
            var controllerNode = ControllerNode <PackageKit> .Allocate();

            var panelName = mPanelNameToCreate;

            if (panelName.IsNotNullAndEmpty())
            {
                var fullScenePath = "Assets/Scenes/TestUIPanels/".CreateDirIfNotExists()
                                    .Append("Test{0}.unity".FillFormat(panelName)).ToString();

                var panelPrefabPath = "Assets/Art/UIPrefab/".CreateDirIfNotExists()
                                      .Append("{0}.prefab".FillFormat(panelName)).ToString();

                if (File.Exists(panelPrefabPath))
                {
                    SingletonProperty <PackageKit> .Instance.GetUtility <IEditorDialogUtility>()
                    .ShowErrorMsg("UI 界面已存在:{0}".FillFormat(panelPrefabPath));

                    return;
                }

                if (File.Exists(fullScenePath))
                {
                    SingletonProperty <PackageKit> .Instance.GetUtility <IEditorDialogUtility>()
                    .ShowErrorMsg("测试场景已存在:{0}".FillFormat(fullScenePath));

                    return;
                }

                RenderEndCommandExecuter.PushCommand(() =>
                {
                    var currentScene = SceneManager.GetActiveScene();
                    EditorSceneManager.SaveScene(currentScene);

                    var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
                    EditorSceneManager.SaveScene(scene, fullScenePath);

                    var uiroot = Resources.Load <GameObject>("UIRoot").Instantiate().Name("UIRoot");

                    var designTransform = uiroot.transform.Find("Design");

                    var gameObj = new GameObject(panelName);
                    gameObj.transform.Parent(designTransform)
                    .LocalScaleIdentity();

                    var rectTransform                = gameObj.AddComponent <RectTransform>();
                    rectTransform.offsetMin          = Vector2.zero;
                    rectTransform.offsetMax          = Vector2.zero;
                    rectTransform.anchoredPosition3D = Vector3.zero;
                    rectTransform.anchorMin          = Vector2.zero;
                    rectTransform.anchorMax          = Vector2.one;

                    var prefab = PrefabUtils.SaveAndConnect(panelPrefabPath, gameObj);

                    EditorSceneManager.SaveScene(scene);

                    // 标记 AssetBundle
                    ResKitAssetsMenu.MarkAB(panelPrefabPath);

                    var tester              = new GameObject("Test{0}".FillFormat(panelName));
                    var uiPanelTester       = tester.AddComponent <UIPanelTester>();
                    uiPanelTester.PanelName = panelName;

                    // 开始生成代码
                    UICodeGenerator.DoCreateCode(new[] { prefab });
                });
            }

            controllerNode.Recycle2Cache();
            controllerNode = null;
        }