Пример #1
0
    public void Btn_up()
    {
        int myIndex = attachedDirData.GetDirIndex();

        if (myIndex == 0)
        {
            return;
        }
        DirData upData = attachedDirData.parentDir.dirs[myIndex - 1];

        attachedDirData.parentDir.dirs[myIndex - 1] = attachedDirData;
        attachedDirData.parentDir.dirs[myIndex]     = upData;
        transform.SetSiblingIndex(transform.GetSiblingIndex() - 1);
        Main.instance.SaveData();
    }
Пример #2
0
    public List <int> GetParentDirArr()
    {
        List <int> indexs = new List <int>();
        DirData    tmp    = parentDir;

        while (tmp.parentDir != null)
        {
            int index = tmp.GetDirIndex();
            indexs.Insert(0, index);
            tmp = tmp.parentDir;
        }
        return(indexs);
    }
Пример #3
0
    /// <summary>
    /// 新建最外层文件夹
    /// </summary>
    public void Btn_baseNewDir()
    {
        Transform dirObj = Instantiate(dirPrefab, baseDirTrsm);

        dirObj.GetComponent <Toggle>().group = baseToggleGroup;
        DirData tmp = new DirData();

        baseDirData.dirs.Add(tmp);
        tmp.parentDir   = baseDirData;
        tmp.dirName     = "默认分组";
        tmp.attachedObj = dirObj;
        DirPrefab tmpDirPrefab = dirObj.GetComponent <DirPrefab>();

        tmpDirPrefab.SetDirName(tmp.dirName);
        tmpDirPrefab.SetPos(0);
        tmpDirPrefab.attachedDirData = tmp;
        dirObj.SetSiblingIndex(tmp.GetDirIndex());
        SaveData();
        ResetSize();
    }
Пример #4
0
    public void Btn_newDir()
    {
        int dirArrCount = attachedDirData.GetParentDirArr().Count;

        if (dirArrCount >= 4)
        {
            return;
        }
        if (attachedDirData.isFold)
        {
            Toggle tmpToggle = GetComponent <Toggle>();
            if (!tmpToggle.isOn)
            {
                tmpToggle.isOn = true;
            }
            else
            {
                OnToggleClick(true);
            }
        }
        Transform parentTrsm = transform.Find("files");
        Transform dirObj     = Instantiate(Main.instance.dirPrefab, parentTrsm);

        dirObj.GetComponent <Toggle>().group = Main.instance.baseToggleGroup;
        DirData tmp = new DirData();

        attachedDirData.dirs.Add(tmp);
        tmp.parentDir   = attachedDirData;
        tmp.dirName     = "默认分组";
        tmp.attachedObj = dirObj;
        DirPrefab tmpDirPrefab = dirObj.GetComponent <DirPrefab>();

        tmpDirPrefab.SetDirName(tmp.dirName);
        tmpDirPrefab.SetPos((dirArrCount + 1) * 100);
        tmpDirPrefab.attachedDirData = tmp;
        dirObj.SetSiblingIndex(tmp.GetDirIndex());
        Main.instance.SaveData();
        Main.instance.ResetSize();
    }