private void SetPage(int _page)
        {
            StudioNode studioNode = (StudioNode)null;

            if (this.dicPage.TryGetValue(SceneLoadScene.page, out studioNode))
            {
                studioNode.select = false;
            }
            _page = Mathf.Clamp(_page, 0, this.pageNum - 1);
            int num = 12 * _page;

            for (int index = 0; index < 12; ++index)
            {
                int n = num + index;
                if (!MathfEx.RangeEqualOn <int>(0, n, this.thumbnailNum - 1))
                {
                    this.buttonThumbnail[index].interactable = false;
                }
                else
                {
                    this.buttonThumbnail[index].texture      = (Texture)PngAssist.LoadTexture(this.listPath[n]);
                    this.buttonThumbnail[index].interactable = true;
                }
            }
            SceneLoadScene.page = _page;
            if (this.dicPage.TryGetValue(SceneLoadScene.page, out studioNode))
            {
                studioNode.select = true;
            }
            Resources.UnloadUnusedAssets();
            GC.Collect();
        }
示例#2
0
        public bool Load(string _file)
        {
            string str = UserData.Path + BackgroundList.dirName + "/" + _file;

            if (!File.Exists(str))
            {
                this.isVisible = false;
                Singleton <Studio.Studio> .Instance.sceneInfo.background = string.Empty;
                return(false);
            }
            Texture texture = (Texture)PngAssist.LoadTexture(str);

            if (Object.op_Equality((Object)texture, (Object)null))
            {
                this.isVisible = false;
                return(false);
            }
            Material material = ((Renderer)this.meshRenderer).get_material();

            material.SetTexture("_MainTex", texture);
            ((Renderer)this.meshRenderer).set_material(material);
            this.isVisible = true;
            Singleton <Studio.Studio> .Instance.sceneInfo.background = _file;
            Resources.UnloadUnusedAssets();
            GC.Collect();
            return(true);
        }
示例#3
0
 public void SetMainTex(string _file)
 {
     if (Object.op_Equality((Object)this.panelComponent, (Object)null))
     {
         return;
     }
     if (_file.IsNullOrEmpty())
     {
         this.itemInfo.panel.filePath = string.Empty;
         this.panelComponent.SetMainTex((Texture2D)null);
         this.textureMain = (Texture2D)null;
     }
     else
     {
         this.itemInfo.panel.filePath = _file;
         string str = UserData.Path + BackgroundList.dirName + "/" + _file;
         if (!File.Exists(str))
         {
             return;
         }
         this.textureMain = PngAssist.LoadTexture(str);
         this.panelComponent.SetMainTex(this.textureMain);
         Resources.UnloadUnusedAssets();
     }
 }
示例#4
0
 private void LoadCharaImage(int _idx)
 {
     if (this.isDelay)
     {
         return;
     }
     this.imageChara.set_texture((Texture)PngAssist.LoadTexture(this.charaFileSort.cfiList[_idx].file));
     ((Graphic)this.imageChara).set_color(Color.get_white());
     Resources.UnloadUnusedAssets();
     GC.Collect();
 }
示例#5
0
    public bool ChangeSaveFrameBack(byte changeNo, bool listUpdate = true)
    {
        if (listUpdate)
        {
            string   str           = "cardframe/Back";
            string[] searchPattern = new string[1] {
                "*.png"
            };
            this.dirFrameBack.lstFile.Clear();
            this.dirFrameBack.CreateFolderInfoEx(DefaultData.Path + str, searchPattern, true);
            this.dirFrameBack.CreateFolderInfoEx(UserData.Path + str, searchPattern, false);
            this.dirFrameBack.SortName(true);
        }
        int fileCount = this.dirFrameBack.GetFileCount();

        if (fileCount == 0)
        {
            return(false);
        }
        int index = this.dirFrameBack.GetIndexFromFileName(this.lastFrameBackName);

        if (index == -1)
        {
            index = 0;
        }
        else
        {
            switch (changeNo)
            {
            case 0:
                index = (index + 1) % fileCount;
                break;

            case 1:
                index = (index + fileCount - 1) % fileCount;
                break;
            }
        }
        Texture texture1 = (Texture)PngAssist.LoadTexture(this.dirFrameBack.lstFile[index].FullPath);

        if (Object.op_Implicit((Object)this.rendBack) && Object.op_Implicit((Object)this.rendBack.get_material()))
        {
            Texture texture2 = this.rendBack.get_material().GetTexture(ChaShader.MainTex);
            if (Object.op_Implicit((Object)texture2))
            {
                Object.Destroy((Object)texture2);
            }
            this.rendBack.get_material().SetTexture(ChaShader.MainTex, texture1);
        }
        this.lastFrameBackName = this.dirFrameBack.lstFile[index].FileName;
        return(true);
    }
示例#6
0
    public bool ChangeSaveFrameFront(byte changeNo, bool listUpdate = true)
    {
        if (listUpdate)
        {
            string   str           = "cardframe/Front";
            string[] searchPattern = new string[1] {
                "*.png"
            };
            this.dirFrameFront.lstFile.Clear();
            this.dirFrameFront.CreateFolderInfoEx(DefaultData.Path + str, searchPattern, true);
            this.dirFrameFront.CreateFolderInfoEx(UserData.Path + str, searchPattern, false);
            this.dirFrameFront.SortName(true);
        }
        int fileCount = this.dirFrameFront.GetFileCount();

        if (fileCount == 0)
        {
            return(false);
        }
        int index = this.dirFrameFront.GetIndexFromFileName(this.lastFrameFrontName);

        if (index == -1)
        {
            index = 0;
        }
        else
        {
            switch (changeNo)
            {
            case 0:
                index = (index + 1) % fileCount;
                break;

            case 1:
                index = (index + fileCount - 1) % fileCount;
                break;
            }
        }
        Texture texture = (Texture)PngAssist.LoadTexture(this.dirFrameFront.lstFile[index].FullPath);

        if (Object.op_Implicit((Object)this.riFront.get_texture()))
        {
            Object.Destroy((Object)this.riFront.get_texture());
        }
        this.riFront.set_texture(texture);
        this.lastFrameFrontName = this.dirFrameFront.lstFile[index].FileName;
        return(true);
    }
示例#7
0
        public string SetPatternTex(int _idx, int _key)
        {
            if (_key <= 0)
            {
                this.itemInfo.colors[_idx].pattern.key      = _key;
                this.itemInfo.colors[_idx].pattern.filePath = string.Empty;
                if (Object.op_Implicit((Object)this.itemComponent))
                {
                    this.itemComponent.SetPatternTex(_idx, (Texture2D)null);
                }
                this.ReleasePatternTex(_idx);
                return("なし");
            }
            PatternSelectInfo patternSelectInfo = Singleton <Studio.Studio> .Instance.patternSelectListCtrl.lstSelectInfo.Find((Predicate <PatternSelectInfo>)(p => p.index == _key));

            string str1 = "なし";

            if (patternSelectInfo != null)
            {
                if (patternSelectInfo.assetBundle.IsNullOrEmpty())
                {
                    string str2 = UserData.Path + "pattern/" + patternSelectInfo.assetName;
                    if (!File.Exists(str2))
                    {
                        return("なし");
                    }
                    this.texturePattern[_idx] = PngAssist.LoadTexture(str2);
                    this.itemInfo.colors[_idx].pattern.key      = -1;
                    this.itemInfo.colors[_idx].pattern.filePath = patternSelectInfo.assetName;
                    str1 = patternSelectInfo.assetName;
                }
                else
                {
                    string assetBundleName = patternSelectInfo.assetBundle.Replace("thumb/", string.Empty);
                    string assetName       = patternSelectInfo.assetName.Replace("thumb_", string.Empty);
                    this.texturePattern[_idx] = CommonLib.LoadAsset <Texture2D>(assetBundleName, assetName, false, string.Empty);
                    this.itemInfo.colors[_idx].pattern.key      = _key;
                    this.itemInfo.colors[_idx].pattern.filePath = string.Empty;
                    str1 = patternSelectInfo.name;
                }
            }
            this.itemComponent.SetPatternTex(_idx, this.texturePattern[_idx]);
            Resources.UnloadUnusedAssets();
            return(str1);
        }
示例#8
0
        private void SetPage(int _page, bool _force = false)
        {
            if (!_force && this.page == _page)
            {
                return;
            }
            _page = Mathf.Clamp(_page, 0, this.pageNum - 1);
            int num = this.thumbnailLimit * _page;

            for (int index = 0; index < this.thumbnailLimit; ++index)
            {
                int n = num + index;
                if (!MathfEx.RangeEqualOn <int>(0, n, this.thumbnailNum - 1))
                {
                    if (_page == 0 && index == 0)
                    {
                        this.rawsThumbnail[index].set_texture(this.textureNoData);
                        ((Behaviour)this.rawsThumbnail[index]).set_enabled(true);
                    }
                    else
                    {
                        ((Behaviour)this.rawsThumbnail[index]).set_enabled(false);
                    }
                    ((Behaviour)this.buttonsThumbnail[index]).set_enabled(false);
                }
                else
                {
                    this.rawsThumbnail[index].set_texture((Texture)PngAssist.LoadTexture(this.listPath[n]));
                    ((Behaviour)this.rawsThumbnail[index]).set_enabled(true);
                    ((Behaviour)this.buttonsThumbnail[index]).set_enabled(true);
                    ((Selectable)this.buttonsThumbnail[index]).set_interactable(true);
                }
            }
            this.page = _page;
            if (_force && this.view.ItemList.FirstOrDefault <LoopListViewItem2>((Func <LoopListViewItem2, bool>)(_v => _v.ItemIndex == _page)) is PageButton pageButton)
            {
                pageButton.Select();
            }
            Resources.UnloadUnusedAssets();
            GC.Collect();
        }
示例#9
0
 public void SetPatternTex(int _idx, string _path)
 {
     if (_path.IsNullOrEmpty())
     {
         this.itemInfo.colors[_idx].pattern.key      = 0;
         this.itemInfo.colors[_idx].pattern.filePath = string.Empty;
         this.itemComponent.SetPatternTex(_idx, (Texture2D)null);
         this.ReleasePatternTex(_idx);
     }
     else
     {
         this.itemInfo.colors[_idx].pattern.key      = -1;
         this.itemInfo.colors[_idx].pattern.filePath = _path;
         if (File.Exists(_path))
         {
             this.texturePattern[_idx] = PngAssist.LoadTexture(_path);
         }
         this.itemComponent.SetPatternTex(_idx, this.texturePattern[_idx]);
         Resources.UnloadUnusedAssets();
     }
 }
        private void SetPage(int _page, bool _force = false)
        {
            if (!_force && this.page == _page)
            {
                return;
            }
            _page = Mathf.Clamp(_page, 0, this.pageNum - 1);
            int num = this.thumbnailLimit * _page;

            for (int index = 0; index < this.thumbnailLimit; ++index)
            {
                int n = num + index;
                if (!MathfEx.RangeEqualOn <int>(0, n, this.thumbnailNum - 1))
                {
                    if (_page == 0 && index == 0)
                    {
                        this.rawsThumbnail[index].set_texture(this.textureNoData);
                        ((Behaviour)this.rawsThumbnail[index]).set_enabled(true);
                    }
                    else
                    {
                        ((Behaviour)this.rawsThumbnail[index]).set_enabled(false);
                    }
                    ((Behaviour)this.buttonsThumbnail[index]).set_enabled(false);
                }
                else
                {
                    this.rawsThumbnail[index].set_texture((Texture)PngAssist.LoadTexture(this.listPath[n]));
                    ((Behaviour)this.rawsThumbnail[index]).set_enabled(true);
                    ((Behaviour)this.buttonsThumbnail[index]).set_enabled(true);
                    ((Selectable)this.buttonsThumbnail[index]).set_interactable(true);
                }
            }
            this.page = _page;
            this.UpdateSelectImage();
            Resources.UnloadUnusedAssets();
            GC.Collect();
        }
示例#11
0
        public bool Load(string _file)
        {
            this.Release();
            string str = UserData.Path + "frame/" + _file;

            if (!File.Exists(str))
            {
                Singleton <Studio.Studio> .Instance.sceneInfo.frame = string.Empty;
                return(false);
            }
            Texture texture = (Texture)PngAssist.LoadTexture(str);

            if (Object.op_Equality((Object)texture, (Object)null))
            {
                return(false);
            }
            this.imageFrame.set_texture(texture);
            ((Behaviour)this.imageFrame).set_enabled(true);
            ((Behaviour)this.cameraUI).set_enabled(true);
            Singleton <Studio.Studio> .Instance.sceneInfo.frame = _file;
            Resources.UnloadUnusedAssets();
            GC.Collect();
            return(true);
        }
示例#12
0
        void SaveScene()
        {
            Studio.Studio.Instance.dicObjectCtrl.Values.ToList().ForEach(x => x.OnSavePreprocessing());
            Studio.Studio.Instance.sceneInfo.cameraSaveData = Studio.Studio.Instance.cameraCtrl.Export();
            string path = GetCategoryFolder() + DateTime.Now.ToString("yyyy_MMdd_HHmm_ss_fff") + ".png";

            Studio.Studio.Instance.sceneInfo.Save(path);
            if (useExternalSavedata)
            {
                Utils.InvokePluginMethod("HSStudioNEOExtSave.StudioNEOExtendSaveMgr", "SaveExtData", path);
                //InvokePluginMethod("HSStudioNEOExtSave.StudioNEOExtendSaveMgr", "SaveExtDataRaw", path);
            }

            var button = CreateSceneButton(imagelist.content.GetComponentInChildren <Image>().transform, PngAssist.LoadTexture(path), path);

            button.transform.SetAsFirstSibling();
        }
        public void Create(
            PatternSelectListCtrl.OnChangeItemFunc _onChangeItemFunc)
        {
            this.onChangeItemFunc = _onChangeItemFunc;
            for (int index = this.objContent.get_transform().get_childCount() - 1; index >= 0; --index)
            {
                Object.Destroy((Object)((Component)this.objContent.get_transform().GetChild(index)).get_gameObject());
            }
            ToggleGroup component1 = (ToggleGroup)this.objContent.GetComponent <ToggleGroup>();
            int         num        = 0;

            for (int index = 0; index < this._lstSelectInfo.Count; ++index)
            {
                GameObject gameObject = (GameObject)Object.Instantiate <GameObject>((M0)this.objTemp);
                PatternSelectInfoComponent component2 = (PatternSelectInfoComponent)gameObject.GetComponent <PatternSelectInfoComponent>();
                component2.info     = this._lstSelectInfo[index];
                component2.info.sic = component2;
                component2.tgl.set_group(component1);
                gameObject.get_transform().SetParent(this.objContent.get_transform(), false);
                this.SetToggleHandler(gameObject, component2);
                component2.img = (Image)gameObject.GetComponent <Image>();
                if (Object.op_Implicit((Object)component2.img))
                {
                    Texture2D texture2D = !this._lstSelectInfo[index].assetBundle.IsNullOrEmpty() ? CommonLib.LoadAsset <Texture2D>(this._lstSelectInfo[index].assetBundle, this._lstSelectInfo[index].assetName, false, string.Empty) : PngAssist.LoadTexture(UserData.Path + "pattern_thumb/" + this._lstSelectInfo[index].assetName);
                    if (Object.op_Implicit((Object)texture2D))
                    {
                        component2.img.set_sprite(Sprite.Create(texture2D, new Rect(0.0f, 0.0f, (float)((Texture)texture2D).get_width(), (float)((Texture)texture2D).get_height()), new Vector2(0.5f, 0.5f)));
                    }
                }
                component2.Disvisible(this._lstSelectInfo[index].disvisible);
                component2.Disable(this._lstSelectInfo[index].disable);
                ++num;
            }
            this.ToggleAllOff();
        }
        void SaveCard()
        {
            switch (currentType)
            {
            case 0:
            {
                Studio.Studio.Instance.dicObjectCtrl.Values.ToList().ForEach(x => x.OnSavePreprocessing());
                Studio.Studio.Instance.sceneInfo.cameraSaveData = Studio.Studio.Instance.cameraCtrl.Export();
                string path = GetCategoryFolder() + DateTime.Now.ToString("yyyy_MMdd_HHmm_ss_fff") + ".png";
                Studio.Studio.Instance.sceneInfo.Save(path);
                var button = CreateSceneButton(GetCurrentList().transform, PngAssist.LoadTexture(path), path);
                button.transform.SetAsFirstSibling();
                break;
            }

            case 1:
            {
                var list = (from v in GuideObjectManager.Instance.selectObjectKey
                            select Studio.Studio.GetCtrlInfo(v) as OCIChar into v
                            where v != null
                            //where v.oiCharInfo.sex == 1
                            select v).ToList();

                if (list.Count > 0)
                {
                    confirmpanel.gameObject.SetActive(false);
                    optionspanel.gameObject.SetActive(false);

                    string format = ".png";
                    string date   = DateTime.Now.ToString("yyyy_MMdd_HHmm_ss_fff");
                    string folder = GetCategoryFolder();

                    foreach (var item in list)
                    {
                        var param    = item.charInfo.fileParam;
                        var charFile = item.oiCharInfo.charFile;
                        var path     = string.Format("{0}{1}_{2}_{3}{4}", folder, param.lastname, param.firstname, date, format);

                        Traverse.Create(charFile).Property("charaFileName").SetValue(Path.GetFileName(path));
                        CustomCapture.CreatePng(ref charFile.pngData, 252, 352, null, null, Camera.main, null);
                        CustomCapture.CreatePng(ref charFile.facePngData, 252, 352, null, null, Camera.main, null);

                        using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write))
                        {
                            if (charFile.SaveCharaFile(fileStream, true))
                            {
                                var button = CreateSceneButton(GetCurrentList().transform, PngAssist.LoadTexture(path), path);
                                button.transform.SetAsFirstSibling();
                            }
                            else
                            {
                                BepInEx.Logger.Log(BepInEx.Logging.LogLevel.Error, "Failed to save card at " + path);
                            }
                        }
                    }
                }

                break;
            }

            case 2:
            {
                break;
            }
            }
        }
示例#15
0
        IEnumerator MakeUI()
        {
            for (int i = 0; i < 2; i++)
            {
                yield return(null);                       // wait for other UI
            }
            var elements    = XElement.Load(Environment.CurrentDirectory + menuFolder + menuFile).Elements();
            var gameObjects = Resources.FindObjectsOfTypeAll <GameObject>().Where(x => x.GetComponent <RectTransform>()).ToList();

            modinfolist = new List <ModInfo>();
            foreach (var item in elements)
            {
                string itemName = (string)item.Element("name");
                var    match    = gameObjects.Where(x => itemName == x.name).ToList();
                if (match.Count > 0)
                {
                    if (match.Count > 1)
                    {
                        Console.WriteLine("[{0}] More than one GameObject found with the name \"{1}\"", GetType().Name, itemName);
                    }
                    modinfolist.Add(new ModInfo(itemName, (string)item.Element("icon"), match[0]));
                }
            }

            int   itemLimit = 4;
            float width     = 59f;
            float height    = ((width + spacingY / 2f) * Mathf.Clamp(modinfolist.Count, 1, itemLimit) + headerSize + marginSizeBig) / 2f + 1f;

            UISystem = UIUtility.CreateNewUISystem("ModMenuManagerCanvas");
            UISystem.GetComponent <CanvasScaler>().referenceResolution = new Vector2(1920f / UIScale, 1080f / UIScale);
            UISystem.gameObject.SetActive(false);
            UISystem.transform.SetAsLastSibling();
            UISystem.GetComponent <Canvas>().sortingOrder = 5;

            var panel = UIUtility.CreatePanel("Panel", UISystem.transform);

            panel.transform.SetRect(1f, 0.4f, 1f, 0.4f, -width, -height, 0f, height);
            panel.color = transparentColor;

            var drag = UIUtility.CreatePanel("Draggable", panel.transform);

            drag.transform.SetRect(0f, 1f, 1f, 1f, 0f, -headerSize);
            drag.color = dragColor;
            UIUtility.MakeObjectDraggable(drag.rectTransform, panel.rectTransform);

            var modlist = UIUtility.CreateScrollView("Modlist", panel.transform);

            modlist.transform.SetRect(0f, 0f, 1f, 1f, marginSizeBig, marginSizeBig, -marginSizeBig, -headerSize - marginSizeBig);
            modlist.gameObject.AddComponent <Mask>();
            modlist.content.gameObject.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
            modlist.GetComponent <Image>().color = new Color(0f, 0f, 0f, 0.01f);
            modlist.movementType = ScrollRect.MovementType.Clamped;
            Destroy(modlist.verticalScrollbar.gameObject);
            modlist.scrollSensitivity = 50f;

            var autogrid = modlist.content.gameObject.AddComponent <AutoGridLayout>();

            autogrid.aspectRatio = 1;
            autogrid.m_IsColumn  = true;
            autogrid.m_Column    = 1;
            autogrid.spacing     = new Vector2(0f, spacingY);

            foreach (var modinfo in modinfolist)
            {
                var button = UIUtility.CreateButton("Button", modlist.content.transform, "");
                button.transform.SetRect(0f, 0f, 1f, 1f, marginSizeSmall, marginSizeSmall, -marginSizeSmall, -marginSizeSmall);
                button.gameObject.AddComponent <Image>();

                string iconPath = Environment.CurrentDirectory + menuFolder + "icons/" + modinfo.Icon;
                if (File.Exists(iconPath))
                {
                    var texture = PngAssist.LoadTexture(iconPath);
                    var sprite  = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                    button.transform.gameObject.AddComponent <Image>();
                    var image = button.transform.gameObject.GetComponent <Image>();
                    image.sprite = sprite;
                }
                else
                {
                    button.GetComponentInChildren <Text>().text = modinfo.Name.Substring(0, 1);
                }

                //modinfo.Canvas.AddComponent<ManageSortingOrder>();

                button.onClick.AddListener(() =>
                {
                    modinfo.Canvas.SetActive(!modinfo.Canvas.activeSelf);
                    SetSortingOrder(modinfo);
                });
            }

            // hack for AutoGridLayout
            yield return(null);

            UISystem.gameObject.SetActive(true);
        }
示例#16
0
        public void CreateUI()
        {
            UISystem = UIUtility.CreateNewUISystem("BetterSceneLoaderCanvas");
            UISystem.GetComponent <CanvasScaler>().referenceResolution = new Vector2(1920f / UIScale, 1080f / UIScale);
            ShowWindow(false);

            mainPanel       = UIUtility.CreatePanel("Panel", UISystem.transform);
            mainPanel.color = backgroundColor;
            UIUtility.AddOutlineToObject(mainPanel.transform, outlineColor);

            var drag = UIUtility.CreatePanel("Draggable", mainPanel.transform);

            drag.transform.SetRect(0f, 1f, 1f, 1f, 0f, -headerSize);
            drag.color = dragColor;
            UIUtility.MakeObjectDraggable(drag.rectTransform, mainPanel.rectTransform);

            nametext = UIUtility.CreateText("Nametext", drag.transform, "Scenes");
            nametext.transform.SetRect(0f, 0f, 1f, 1f, 340f, 0f, -buttonSize * 2f);
            nametext.alignment = TextAnchor.MiddleCenter;

            var close = UIUtility.CreateButton("CloseButton", drag.transform, "");

            close.transform.SetRect(1f, 0f, 1f, 1f, -buttonSize * 2f);
            close.onClick.AddListener(() => ShowWindow(false));

            var x1 = UIUtility.CreatePanel("x1", close.transform);

            x1.transform.SetRect(0f, 0f, 1f, 1f, 8f, 0f, -8f);
            x1.rectTransform.eulerAngles = new Vector3(0f, 0f, 45f);
            x1.color = new Color(0f, 0f, 0f, 1f);
            var x2 = UIUtility.CreatePanel("x2", close.transform);

            x2.transform.SetRect(0f, 0f, 1f, 1f, 8f, 0f, -8f);
            x2.rectTransform.eulerAngles = new Vector3(0f, 0f, -45f);
            x2.color = new Color(0f, 0f, 0f, 1f);

            var category = UIUtility.CreateDropdown("Dropdown", drag.transform, "Categories");

            category.transform.SetRect(0f, 0f, 0f, 1f, 0f, 0f, 100f);
            category.captionText.transform.SetRect(0f, 0f, 1f, 1f, 0f, 2f, -15f, -2f);
            category.captionText.alignment = TextAnchor.MiddleCenter;
            category.options = GetCategories();
            category.onValueChanged.AddListener(x =>
            {
                currentCategoryFolder = CategoryFolders[category.options[x].text];
                imagelist.content.GetComponentInChildren <Image>().gameObject.SetActive(false);
                imagelist.content.anchoredPosition = new Vector2(0f, 0f);
                PopulateGrid();
            });

            var refresh = UIUtility.CreateButton("RefreshButton", drag.transform, "Refresh");

            refresh.transform.SetRect(0f, 0f, 0f, 1f, 100f, 0f, 180f);
            refresh.onClick.AddListener(ReloadImages);

            var save = UIUtility.CreateButton("SaveButton", drag.transform, "Save");

            save.transform.SetRect(0f, 0f, 0f, 1f, 180f, 0f, 260f);
            save.interactable = false;
            save.onClick.AddListener(() =>
            {
                string path = Path.Combine(currentCategoryFolder, DateTime.Now.ToString("yyyy_MMdd_HHmm_ss_fff") + ".png");
                OnSaveButtonClick(path);
                var button = CreateSceneButton(imagelist.content.GetComponentInChildren <Image>().transform, PngAssist.LoadTexture(path), path);
                button.transform.SetAsFirstSibling();
            });

            var folder = UIUtility.CreateButton("FolderButton", drag.transform, "Folder");

            folder.transform.SetRect(0f, 0f, 0f, 1f, 260f, 0f, 340f);
            folder.onClick.AddListener(() => OnFolderButtonClick(scenePath));

            var loadingPanel = UIUtility.CreatePanel("LoadingIconPanel", drag.transform);

            loadingPanel.transform.SetRect(0f, 0f, 0f, 1f, 340f, 0f, 340f + headerSize);
            loadingPanel.color = new Color(0f, 0f, 0f, 0f);
            var loadingIcon = UIUtility.CreatePanel("LoadingIcon", loadingPanel.transform);

            loadingIcon.transform.SetRect(0.1f, 0.1f, 0.9f, 0.9f);
            var loadiconTex = PngAssist.ChangeTextureFromByte(Resource.GetResourceAsBytes(typeof(SceneLoaderUI).Assembly, "Resources.loadicon"));

            loadingIcon.sprite = Sprite.Create(loadiconTex, new Rect(0, 0, loadiconTex.width, loadiconTex.height), new Vector2(0.5f, 0.5f));
            LoadingIcon.Init(loadingIcon, -5f);

            imagelist = UIUtility.CreateScrollView("Imagelist", mainPanel.transform);
            imagelist.transform.SetRect(0f, 0f, 1f, 1f, marginSize, marginSize, -marginSize, -headerSize - marginSize / 2f);
            imagelist.gameObject.AddComponent <Mask>();
            imagelist.content.gameObject.AddComponent <VerticalLayoutGroup>();
            imagelist.content.gameObject.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
            imagelist.verticalScrollbar.GetComponent <RectTransform>().offsetMin        = new Vector2(scrollOffsetX, 0f);
            imagelist.viewport.offsetMax = new Vector2(scrollOffsetX, 0f);
            imagelist.movementType       = ScrollRect.MovementType.Clamped;

            optionspanel = UIUtility.CreatePanel("ButtonPanel", imagelist.transform);
            optionspanel.gameObject.SetActive(false);

            confirmpanel = UIUtility.CreatePanel("ConfirmPanel", imagelist.transform);
            confirmpanel.gameObject.SetActive(false);

            yesbutton = UIUtility.CreateButton("YesButton", confirmpanel.transform, "Y");
            yesbutton.transform.SetRect(0f, 0f, 0.5f, 1f);
            yesbutton.onClick.AddListener(() => OnDeleteButtonClick(currentPath));

            nobutton = UIUtility.CreateButton("NoButton", confirmpanel.transform, "N");
            nobutton.transform.SetRect(0.5f, 0f, 1f, 1f);
            nobutton.onClick.AddListener(() => confirmpanel.gameObject.SetActive(false));

            var loadbutton = UIUtility.CreateButton("LoadButton", optionspanel.transform, "Load");

            loadbutton.transform.SetRect(0f, 0f, 0.3f, 1f);
            loadbutton.onClick.AddListener(() =>
            {
                confirmpanel.gameObject.SetActive(false);
                optionspanel.gameObject.SetActive(false);
                OnLoadButtonClick(currentPath);
                if (BetterSceneLoaderCore.AutoClose.Value)
                {
                    ShowWindow(false);
                }
            });

            var importbutton = UIUtility.CreateButton("ImportButton", optionspanel.transform, "Import");

            importbutton.transform.SetRect(0.35f, 0f, 0.65f, 1f);
            importbutton.onClick.AddListener(() =>
            {
                OnImportButtonClick(currentPath);
                confirmpanel.gameObject.SetActive(false);
                optionspanel.gameObject.SetActive(false);
            });

            var deletebutton = UIUtility.CreateButton("DeleteButton", optionspanel.transform, "Delete");

            deletebutton.transform.SetRect(0.7f, 0f, 1f, 1f);
            deletebutton.onClick.AddListener(() =>
            {
                confirmpanel.gameObject.SetActive(true);
                currentButton.gameObject.SetActive(false);
                confirmpanel.gameObject.SetActive(false);
                optionspanel.gameObject.SetActive(false);
            });

            var pluginiconTex = PngAssist.ChangeTextureFromByte(Resource.GetResourceAsBytes(typeof(SceneLoaderUI).Assembly, "Resources.pluginicon"));

            toolbarToggle = CustomToolbarButtons.AddLeftToolbarToggle(pluginiconTex, false, ShowWindow);

            UpdateWindow();
            PopulateGrid();
        }
示例#17
0
        void SaveScene(string filepath = "", bool resave = false)
        {
            if (bSavingInProgress)
            {
                return;
            }
            string category_path = GetCategoryFolder();

            if (!Directory.Exists(category_path))
            {
                GetCategories();
                return;
            }
            bSavingInProgress = true;

            Studio.Studio.Instance.dicObjectCtrl.Values.ToList().ForEach(x => x.OnSavePreprocessing());
            Studio.Studio.Instance.sceneInfo.cameraSaveData = Studio.Studio.Instance.cameraCtrl.Export();
            string path = "";

            if (filepath == "")
            {
                path += category_path + DateTime.Now.ToString("yyyy_MMdd_HHmm_ss_fff") + ".png";
            }
            else
            {
                path = filepath;
            }
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            Studio.Studio.Instance.sceneInfo.Save(path);
            if (useExternalSavedata)
            {
                Utils.InvokePluginMethod("HSStudioNEOExtSave.StudioNEOExtendSaveMgr", "SaveExtData", path);
                //InvokePluginMethod("HSStudioNEOExtSave.StudioNEOExtendSaveMgr", "SaveExtDataRaw", path);
            }

            if (!resave)
            {
                var button = CreateSceneButton(imagelist.content.GetComponentInChildren <Image>().transform, PngAssist.LoadTexture(path), path);
                button.transform.SetAsFirstSibling();
                lastLoadedMark_filePath = path;
                SetLastLoadedMarkParentObj(button.transform, true);
            }

            bSavingInProgress = false;
        }