Ejemplo n.º 1
0
        private List <ProfilePreset> LoadListOfPresets()
        {
            List <ProfilePreset> presets = new List <ProfilePreset>();

            string[] guids = AssetDatabase.FindAssets("t:SkyProfile");

            if (guids == null || guids.Length == 0)
            {
                return(presets);
            }

            foreach (string guid in guids)
            {
                string presetPath = AssetDatabase.GUIDToAssetPath(guid);
                if (presetPath == null)
                {
                    Debug.LogError("Failed to get name for profile GUID: " + guid);
                    continue;
                }
                string presetName = ObjectNames.NicifyVariableName(Path.GetFileNameWithoutExtension(presetPath));
                string menuName   = Path.GetDirectoryName(presetPath) + "/" + presetName;
                menuName = SkyEditorUtility.WindowsPathToUnixPath(menuName);

                string presetDirPrefix = "Assets/" + SkyEditorUtility.PACKAGE_DIR_NAME + "/Internal/Presets/";
                if (menuName.StartsWith(presetDirPrefix))
                {
                    menuName = menuName.Remove(0, presetDirPrefix.Length);
                }
                else
                {
                    menuName = "Your Project/" + menuName;
                }

                presets.Add(new ProfilePreset(guid, presetPath, presetName, menuName));
            }

            presets.Sort(delegate(ProfilePreset p1, ProfilePreset p2)
            {
                return(p1.menuName.CompareTo(p2.menuName));
            });

            return(presets);
        }