/// <summary>
        /// Create a new folder and add a collider to it
        /// </summary>
        public void CreateMaskingFolder()
        {
            TreeNodeObject selectedNode = null;

            if (StudioCustomMasking.AddNewMaskToSelected.Value)
            {
                selectedNode = GetNonMaskingTreeNodeObject();
            }

            OCIFolder ociFolder = AddObjectFolder.Add();

            Singleton <UndoRedoManager> .Instance.Clear();

            AddColliderToFolder(ociFolder);

            if (selectedNode != null)
            {
                Studio.Studio.Instance.treeNodeCtrl.SetParent(ociFolder.treeNodeObject, selectedNode);
                selectedNode.SetTreeState(TreeNodeObject.TreeState.Open);
                var workspaceCtrl = (WorkspaceCtrl)Traverse.Create(Studio.Studio.Instance).Field("m_WorkspaceCtrl").GetValue();
                workspaceCtrl.UpdateUI();
            }

            if (Studio.Studio.optionSystem.autoSelect && ociFolder != null)
            {
                Studio.Studio.Instance.treeNodeCtrl.SelectSingle(ociFolder.treeNodeObject);
            }
        }
예제 #2
0
        public static Folder add(string name)
        {
            OCIFolder fold = AddObjectFolder.Add();
            Folder    obj  = new Folder(fold);

            if (name != null)
            {
                obj.name = name;
            }
            return(obj);
        }
예제 #3
0
파일: TextPlugin.cs 프로젝트: jallex1515/KK
        /// <summary>
        /// 創建設定資料夾結構,或是變更設定中的特定項目
        /// </summary>
        /// <param name="textTreeNodeObject">要變更的OCIFolder.treeNodeObject</param>
        /// <param name="config">要設定的項目</param>
        public static void MakeAndSetConfigStructure(TreeNodeObject textTreeNodeObject, Config config = Config.All)
        {
            Patches.isCreatingTextStructure = true;
            OCIFolder    textOCIFolder = Studio.Studio.GetCtrlInfo(textTreeNodeObject) as OCIFolder;
            TextMesh     t             = textOCIFolder.objectItem.GetComponentInChildren <TextMesh>(true);
            MeshRenderer m             = textOCIFolder.objectItem.GetComponentInChildren <MeshRenderer>(true);
            TreeNodeCtrl treeNodeCtrl  = Singleton <Studio.Studio> .Instance.treeNodeCtrl;

            TreeNodeObject nConfig = doMain(Patches.TextConfigPrefix, "", textTreeNodeObject);

            if (config == Config.Font || config == Config.All)
            {
                doMain(Patches.TextConfigFontPrefix, t.font.name, nConfig);
            }
            if (config == Config.FontSize || config == Config.All)
            {
                doMain(Patches.TextConfigFontSizePrefix, (t.characterSize * 500).ToString(), nConfig);
            }
            if (config == Config.FontStyle || config == Config.All)
            {
                doMain(Patches.TextConfigFontStylePrefix, t.fontStyle.ToString(), nConfig);
            }
            if (config == Config.Color || config == Config.All)
            {
                doMain(Patches.TextConfigColorPrefix, '#' + ColorUtility.ToHtmlStringRGBA(m.material.color), nConfig);
            }
            if (config == Config.Anchor || config == Config.All)
            {
                doMain(Patches.TextConfigAnchorPrefix, t.anchor.ToString(), nConfig);
            }
            if (config == Config.Align || config == Config.All)
            {
                doMain(Patches.TextConfigAlignPrefix, t.alignment.ToString(), nConfig);
            }

            Patches.isCreatingTextStructure = false;

            TreeNodeObject doMain(string prefix, string value, TreeNodeObject nRoot)
            {
                TreeNodeObject node = nRoot.child?.Where((x) =>
                                                         Studio.Studio.GetCtrlInfo(x).objectInfo.kind == 3 &&
                                                         (Studio.Studio.GetCtrlInfo(x) is OCIFolder y) &&
                                                         y.name.Contains(prefix)
                                                         ).FirstOrDefault();
                OCIFolder folder;

                if (null == node)
                {
                    //沒有找到就創建
                    folder = AddObjectFolder.Add();
                    treeNodeCtrl.SetParent(folder.treeNodeObject, nRoot);
                    folder.objectInfo.changeAmount.Reset();
                    node = folder.treeNodeObject;
                }
                else
                {
                    folder = Studio.Studio.GetCtrlInfo(node) as OCIFolder;
                }
                folder.name = folder.objectItem.name = prefix + value;
                return(node);
            }
        }