public static List <string> GetAvailableFilesWithExtensionOnTheHDD(PresetFileLocation fileLocation, string fileExtensionWithoutDot)
        {
            List <string> exentionFromFolders = PresetLibraryLocations.GetFilesWithExentionFromFolders(PresetLibraryLocations.GetDirectoryPaths(fileLocation), fileExtensionWithoutDot);

            for (int index = 0; index < exentionFromFolders.Count; ++index)
            {
                exentionFromFolders[index] = PresetLibraryLocations.ConvertToUnitySeperators(exentionFromFolders[index]);
            }
            return(exentionFromFolders);
        }
Beispiel #2
0
        private string CreateNewLibraryCallback(string libraryName, PresetFileLocation fileLocation)
        {
            string presetLibraryPathWithoutExtension = Path.Combine(PresetLibraryLocations.GetDefaultFilePathForFileLocation(fileLocation), libraryName);

            if (this.CreateNewLibrary(presetLibraryPathWithoutExtension) != null)
            {
                this.currentLibraryWithoutExtension = presetLibraryPathWithoutExtension;
            }
            return(ScriptableSingleton <PresetLibraryManager> .instance.GetLastError());
        }
Beispiel #3
0
        // Returns an error string. If no errors occured then null is returned
        string CreateNewLibraryCallback(string libraryName, PresetFileLocation fileLocation)
        {
            string defaultPath          = PresetLibraryLocations.GetDefaultFilePathForFileLocation(fileLocation);
            string pathWithoutExtension = Path.Combine(defaultPath, libraryName);

            if (CreateNewLibrary(pathWithoutExtension) != null)
            {
                currentLibraryWithoutExtension = pathWithoutExtension;
            }
            return(PresetLibraryManager.instance.GetLastError());
        }
Beispiel #4
0
        public static List <string> GetAvailableFilesWithExtensionOnTheHDD(PresetFileLocation fileLocation, string fileExtensionWithoutDot)
        {
            List <string> directoryPaths = PresetLibraryLocations.GetDirectoryPaths(fileLocation);
            List <string> filesWithExentionFromFolders = PresetLibraryLocations.GetFilesWithExentionFromFolders(directoryPaths, fileExtensionWithoutDot);

            for (int i = 0; i < filesWithExentionFromFolders.Count; i++)
            {
                filesWithExentionFromFolders[i] = PresetLibraryLocations.ConvertToUnitySeperators(filesWithExentionFromFolders[i]);
            }
            return(filesWithExentionFromFolders);
        }
Beispiel #5
0
 public PresetLibraryEditor(ScriptableObjectSaveLoadHelper <T> helper, PresetLibraryEditorState state, System.Action <int, object> itemClickedCallback)
 {
     this.m_SaveLoadHelper                    = helper;
     this.m_State                             = state;
     this.m_ItemClickedCallback               = itemClickedCallback;
     this.settingsMenuRightMargin             = 10f;
     this.useOnePixelOverlappedGrid           = false;
     this.alwaysShowScrollAreaHorizontalLines = true;
     this.marginsForList                      = new RectOffset(10, 10, 5, 5);
     this.marginsForGrid                      = new RectOffset(5, 5, 5, 5);
     this.m_PresetLibraryFileLocation         = PresetLibraryLocations.GetFileLocationFromPath(this.currentLibraryWithoutExtension);
 }
Beispiel #6
0
 private static string GetExtension(CurveLibraryType curveLibraryType)
 {
     if (curveLibraryType == CurveLibraryType.Unbounded)
     {
         return(PresetLibraryLocations.GetCurveLibraryExtension(false));
     }
     if (curveLibraryType != CurveLibraryType.NormalizedZeroToOne)
     {
         Debug.LogError("Enum not handled!");
         return("curves");
     }
     return(PresetLibraryLocations.GetCurveLibraryExtension(true));
 }
        private static string GetExtension(CurveLibraryType curveLibraryType)
        {
            switch (curveLibraryType)
            {
            case CurveLibraryType.Unbounded:
                return(PresetLibraryLocations.GetCurveLibraryExtension(false));

            case CurveLibraryType.NormalizedZeroToOne:
                return(PresetLibraryLocations.GetCurveLibraryExtension(true));
            }
            Debug.LogError("Enum not handled!");
            return("curves");
        }
Beispiel #8
0
        private CurveLibraryType GetCurveLibraryTypeFromExtension(string extension)
        {
            string curveLibraryExtension = PresetLibraryLocations.GetCurveLibraryExtension(true);
            string str2 = PresetLibraryLocations.GetCurveLibraryExtension(false);

            if (!extension.Equals(curveLibraryExtension, StringComparison.OrdinalIgnoreCase))
            {
                if (extension.Equals(str2, StringComparison.OrdinalIgnoreCase))
                {
                    return(CurveLibraryType.Unbounded);
                }
                Debug.LogError("Extension not recognized!");
            }
            return(CurveLibraryType.NormalizedZeroToOne);
        }
Beispiel #9
0
 public PresetLibraryEditor(ScriptableObjectSaveLoadHelper <T> helper, PresetLibraryEditorState state, Action <int, object> itemClickedCallback)
 {
     this.m_DragState                         = new DragState <T>();
     this.m_Grid                              = new VerticalGrid();
     this.m_MinMaxPreviewHeight               = new Vector2(14f, 64f);
     this.m_PreviewAspect                     = 8f;
     this.m_ShowAddNewPresetItem              = true;
     this.m_IsOpenForEdit                     = true;
     this.m_SaveLoadHelper                    = helper;
     this.m_State                             = state;
     this.m_ItemClickedCallback               = itemClickedCallback;
     this.settingsMenuRightMargin             = 10f;
     this.useOnePixelOverlappedGrid           = false;
     this.alwaysShowScrollAreaHorizontalLines = true;
     this.marginsForList                      = new RectOffset(10, 10, 5, 5);
     this.marginsForGrid                      = new RectOffset(5, 5, 5, 5);
     this.m_PresetLibraryFileLocation         = PresetLibraryLocations.GetFileLocationFromPath(this.currentLibraryWithoutExtension);
 }
 public void InitIfNeeded()
 {
     if (this.m_CurveLibraryEditorState == null)
     {
         this.m_CurveLibraryEditorState = new PresetLibraryEditorState(this.GetEditorPrefBaseName());
         this.m_CurveLibraryEditorState.TransferEditorPrefsState(true);
     }
     if (this.m_CurveLibraryEditor == null)
     {
         string particleCurveLibraryExtension = PresetLibraryLocations.GetParticleCurveLibraryExtension(this.m_DoubleCurve.IsSingleCurve(), this.m_DoubleCurve.signedRange);
         ScriptableObjectSaveLoadHelper <DoubleCurvePresetLibrary> helper = new ScriptableObjectSaveLoadHelper <DoubleCurvePresetLibrary>(particleCurveLibraryExtension, SaveType.Text);
         this.m_CurveLibraryEditor = new PresetLibraryEditor <DoubleCurvePresetLibrary>(helper, this.m_CurveLibraryEditorState, new Action <int, object>(this.ItemClickedCallback));
         PresetLibraryEditor <DoubleCurvePresetLibrary> expr_7B = this.m_CurveLibraryEditor;
         expr_7B.addDefaultPresets = (Action <PresetLibrary>)Delegate.Combine(expr_7B.addDefaultPresets, new Action <PresetLibrary>(this.AddDefaultPresetsToLibrary));
         this.m_CurveLibraryEditor.presetsWasReordered = new Action(this.PresetsWasReordered);
         this.m_CurveLibraryEditor.previewAspect       = 4f;
         this.m_CurveLibraryEditor.minMaxPreviewHeight = new Vector2(24f, 24f);
         this.m_CurveLibraryEditor.showHeader          = true;
     }
 }
        public void InitIfNeeded()
        {
            if (m_CurveLibraryEditorState == null)
            {
                m_CurveLibraryEditorState = new PresetLibraryEditorState(GetEditorPrefBaseName());
                m_CurveLibraryEditorState.TransferEditorPrefsState(true);
            }

            if (m_CurveLibraryEditor == null)
            {
                var extension      = PresetLibraryLocations.GetParticleCurveLibraryExtension(m_DoubleCurve.IsSingleCurve(), m_DoubleCurve.signedRange);
                var saveLoadHelper = new ScriptableObjectSaveLoadHelper <DoubleCurvePresetLibrary>(extension, SaveType.Text);
                m_CurveLibraryEditor = new PresetLibraryEditor <DoubleCurvePresetLibrary>(saveLoadHelper, m_CurveLibraryEditorState, ItemClickedCallback);
                m_CurveLibraryEditor.addDefaultPresets  += AddDefaultPresetsToLibrary;
                m_CurveLibraryEditor.presetsWasReordered = PresetsWasReordered;
                m_CurveLibraryEditor.previewAspect       = 4f;
                m_CurveLibraryEditor.minMaxPreviewHeight = new Vector2(24f, 24f);
                m_CurveLibraryEditor.showHeader          = true;
            }
        }
        private static List <string> GetDirectoryPaths(PresetFileLocation fileLocation)
        {
            List <string> stringList = new List <string>();

            switch (fileLocation)
            {
            case PresetFileLocation.PreferencesFolder:
                stringList.Add(PresetLibraryLocations.GetDefaultFilePathForFileLocation(PresetFileLocation.PreferencesFolder));
                break;

            case PresetFileLocation.ProjectFolder:
                string[] directories = Directory.GetDirectories("Assets/", "Editor", SearchOption.AllDirectories);
                stringList.AddRange((IEnumerable <string>)directories);
                break;

            default:
                Debug.LogError((object)"Enum not handled!");
                break;
            }
            return(stringList);
        }
Beispiel #13
0
        // Returns an error string. If no errors occured then null is returned
        string CreateNewLibraryCallback(string libraryName, PresetFileLocation fileLocation)
        {
            if (libraryName.Contains(":"))
            {
                return("A filename cannot contain the following character ':'");
            }

            string defaultPath = PresetLibraryLocations.GetDefaultFilePathForFileLocation(fileLocation);

            if (libraryName.StartsWith("\\") || libraryName.StartsWith("/"))
            {
                libraryName = libraryName.Substring(1);
            }

            string pathWithoutExtension = Path.Combine(defaultPath, libraryName);

            if (CreateNewLibrary(pathWithoutExtension) != null)
            {
                currentLibraryWithoutExtension = pathWithoutExtension;
            }
            return(PresetLibraryManager.instance.GetLastError());
        }
Beispiel #14
0
        private static List <string> GetDirectoryPaths(PresetFileLocation fileLocation)
        {
            List <string> list = new List <string>();

            if (fileLocation != PresetFileLocation.PreferencesFolder)
            {
                if (fileLocation != PresetFileLocation.ProjectFolder)
                {
                    Debug.LogError("Enum not handled!");
                }
                else
                {
                    string[] directories = Directory.GetDirectories("Assets/", "Editor", SearchOption.AllDirectories);
                    list.AddRange(directories);
                }
            }
            else
            {
                list.Add(PresetLibraryLocations.GetDefaultFilePathForFileLocation(PresetFileLocation.PreferencesFolder));
            }
            return(list);
        }
 private string GetEditorPrefBaseName() =>
 PresetLibraryLocations.GetParticleCurveLibraryExtension(this.m_DoubleCurve.IsSingleCurve(), this.m_DoubleCurve.signedRange);
 string GetEditorPrefBaseName()
 {
     return(PresetLibraryLocations.GetParticleCurveLibraryExtension(m_DoubleCurve.IsSingleCurve(), m_DoubleCurve.signedRange));
 }
Beispiel #17
0
 public void GetAvailableLibraries <T>(ScriptableObjectSaveLoadHelper <T> helper, out List <string> preferencesLibs, out List <string> projectLibs) where T : ScriptableObject
 {
     preferencesLibs = PresetLibraryLocations.GetAvailableFilesWithExtensionOnTheHDD(PresetFileLocation.PreferencesFolder, helper.fileExtensionWithoutDot);
     projectLibs     = PresetLibraryLocations.GetAvailableFilesWithExtensionOnTheHDD(PresetFileLocation.ProjectFolder, helper.fileExtensionWithoutDot);
 }
 public void InitIfNeeded()
 {
     if (this.m_CurveLibraryEditorState == null)
     {
         this.m_CurveLibraryEditorState = new PresetLibraryEditorState(this.GetEditorPrefBaseName());
         this.m_CurveLibraryEditorState.TransferEditorPrefsState(true);
     }
     if (this.m_CurveLibraryEditor != null)
     {
         return;
     }
     this.m_CurveLibraryEditor = new PresetLibraryEditor <DoubleCurvePresetLibrary>(new ScriptableObjectSaveLoadHelper <DoubleCurvePresetLibrary>(PresetLibraryLocations.GetParticleCurveLibraryExtension(this.m_DoubleCurve.IsSingleCurve(), this.m_DoubleCurve.signedRange), SaveType.Text), this.m_CurveLibraryEditorState, new System.Action <int, object>(this.ItemClickedCallback));
     this.m_CurveLibraryEditor.addDefaultPresets  += new System.Action <PresetLibrary>(this.AddDefaultPresetsToLibrary);
     this.m_CurveLibraryEditor.presetsWasReordered = new System.Action(this.PresetsWasReordered);
     this.m_CurveLibraryEditor.previewAspect       = 4f;
     this.m_CurveLibraryEditor.minMaxPreviewHeight = new Vector2(24f, 24f);
     this.m_CurveLibraryEditor.showHeader          = true;
 }