public T CreateLibrary <T>(ScriptableObjectSaveLoadHelper <T> helper, string presetLibraryPathWithoutExtension) where T : ScriptableObject
        {
            string libaryNameFromPath = this.GetLibaryNameFromPath(presetLibraryPathWithoutExtension);

            if (!InternalEditorUtility.IsValidFileName(libaryNameFromPath))
            {
                string displayStringOfInvalidCharsOfFileName = InternalEditorUtility.GetDisplayStringOfInvalidCharsOfFileName(libaryNameFromPath);
                if (displayStringOfInvalidCharsOfFileName.Length > 0)
                {
                    PresetLibraryManager.s_LastError = string.Format("A library filename cannot contain the following character{0}:  {1}", (displayStringOfInvalidCharsOfFileName.Length <= 1) ? string.Empty : "s", displayStringOfInvalidCharsOfFileName);
                }
                else
                {
                    PresetLibraryManager.s_LastError = "Invalid filename";
                }
                return((T)((object)null));
            }
            if (this.GetLibrary <T>(helper, presetLibraryPathWithoutExtension) != null)
            {
                PresetLibraryManager.s_LastError = "Library '" + libaryNameFromPath + "' already exists! Ensure a unique name.";
                return((T)((object)null));
            }
            T t = helper.Create();

            t.hideFlags = this.libraryHideFlag;
            PresetLibraryManager.LibraryCache presetLibraryCache = this.GetPresetLibraryCache(helper.fileExtensionWithoutDot);
            presetLibraryCache.loadedLibraries.Add(t);
            presetLibraryCache.loadedLibraryIDs.Add(presetLibraryPathWithoutExtension);
            PresetLibraryManager.s_LastError = null;
            return(t);
        }
예제 #2
0
        public T CreateLibrary <T>(ScriptableObjectSaveLoadHelper <T> helper, string presetLibraryPathWithoutExtension) where T : ScriptableObject
        {
            string libaryNameFromPath = this.GetLibaryNameFromPath(presetLibraryPathWithoutExtension);

            if (!InternalEditorUtility.IsValidFileName(libaryNameFromPath))
            {
                string displayStringOfInvalidCharsOfFileName = InternalEditorUtility.GetDisplayStringOfInvalidCharsOfFileName(libaryNameFromPath);
                if (displayStringOfInvalidCharsOfFileName.Length > 0)
                {
                    s_LastError = $"A library filename cannot contain the following character{(displayStringOfInvalidCharsOfFileName.Length <= 1) ? "" : "s"}:  {displayStringOfInvalidCharsOfFileName}";
                }
                else
                {
                    s_LastError = "Invalid filename";
                }
                return(null);
            }
            if (this.GetLibrary <T>(helper, presetLibraryPathWithoutExtension) != null)
            {
                s_LastError = "Library '" + libaryNameFromPath + "' already exists! Ensure a unique name.";
                return(null);
            }
            T item = helper.Create();

            item.hideFlags = this.libraryHideFlag;
            LibraryCache presetLibraryCache = this.GetPresetLibraryCache(helper.fileExtensionWithoutDot);

            presetLibraryCache.loadedLibraries.Add(item);
            presetLibraryCache.loadedLibraryIDs.Add(presetLibraryPathWithoutExtension);
            s_LastError = null;
            return(item);
        }
예제 #3
0
        public T CreateLibrary <T>(ScriptableObjectSaveLoadHelper <T> helper, string presetLibraryPathWithoutExtension) where T : ScriptableObject
        {
            string libraryName = GetLibaryNameFromPath(presetLibraryPathWithoutExtension);

            if (!InternalEditorUtility.IsValidFileName(libraryName))
            {
                string invalid = InternalEditorUtility.GetDisplayStringOfInvalidCharsOfFileName(libraryName);
                if (invalid.Length > 0)
                {
                    s_LastError = string.Format("A library filename cannot contain the following character{0}:  {1}", invalid.Length > 1 ? "s" : "", invalid);
                }
                else
                {
                    s_LastError = "Invalid filename";
                }
                return(null);
            }

            if (GetLibrary(helper, presetLibraryPathWithoutExtension) != null)
            {
                s_LastError = "Library '" + libraryName + "' already exists! Ensure a unique name.";
                return(null);
            }

            T library = helper.Create();

            library.hideFlags = libraryHideFlag;
            LibraryCache set = GetPresetLibraryCache(helper.fileExtensionWithoutDot);

            set.loadedLibraries.Add(library);
            set.loadedLibraryIDs.Add(presetLibraryPathWithoutExtension);
            s_LastError = null;
            return(library);
        }