Beispiel #1
0
        public static void ShowLine(string label, ref string value, string defaultValue, bool showBrowse = true)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(label + ":", GUILayout.Width(130));
            value = EditorGUILayout.TextField(value);
            if (showBrowse)
            {
                if (GUILayout.Button("Browse", GUILayout.Width(100)))
                {
                    var openPath   = string.IsNullOrEmpty(value) ? defaultValue : value;
                    var selectPath = UnityEditor.EditorUtility.OpenFolderPanel("Choose " + label, Application.dataPath + openPath, "");
                    if (!string.IsNullOrEmpty(selectPath))
                    {
                        var selectDir   = LTDirInfo.CreateDirInfo(selectPath);
                        var dataPathDir = LTDirInfo.CreateDirInfo(Application.dataPath);

                        var matchDirPath = selectDir.Match(dataPathDir);

                        value = matchDirPath;
                    }
                }
            }

            if (GUILayout.Button("Reset", GUILayout.Width(100)))
            {
                value = defaultValue;
            }
            EditorGUILayout.EndHorizontal();
        }
Beispiel #2
0
        private static LTDirInfo _Init(string fullDirPath)
        {
            var dirPath   = LTUtils.GetDirPath(fullDirPath);
            var splitDirs = dirPath.Split("/");
            var dirList   = new LTDirInfo[splitDirs.Length];

            for (var i = 0; i < dirList.Length; ++i)
            {
                var splitDir = splitDirs[i];
                var dir      = new LTDirInfo(splitDir);
                dirList[i] = dir;
            }
            for (var i = 1; i < dirList.Length; ++i)
            {
                dirList[i - 1].Connect(dirList[i]);
            }
            return(dirList[splitDirs.Length - 1]);
        }
Beispiel #3
0
        public string Match(LTDirInfo source)
        {
            var selfFull   = GetFull();
            var sourceFull = source.GetFull();

            var matchIndex      = 0;
            var sourceFullIndex = sourceFull.Length;

            for (; matchIndex < selfFull.Length && matchIndex < sourceFull.Length; ++matchIndex)
            {
                if (selfFull[matchIndex].currentName != sourceFull[matchIndex].currentName)
                {
                    break;
                }
            }


            // 返回子路径
            var finalStr = "";

            if (matchIndex == 1)
            {
                // 返回全路径
                finalStr = selfFull[0].currentName + "/";
            }
            else
            {
                finalStr = "/";
            }

            // 拼接返回符
            for (var i = matchIndex; i < sourceFullIndex; ++i)
            {
                finalStr += "../";
            }

            // 拼接后路劲
            for (var i = matchIndex; i < selfFull.Length; ++i)
            {
                finalStr += selfFull[i].currentName + "/";
            }

            return(finalStr);
        }
Beispiel #4
0
 public void Connect(LTDirInfo nextDir)
 {
     nextDir.upDir = this;
 }