コード例 #1
0
        public string GenerateSourceCode(ScenesData data, SceneSearcherPreferences preferences)
        {
            var menuItemTemplate = preferences.ProjectName + "/Scenes/";
            var scenesSorted     = data.Scenes;

            scenesSorted = preferences.SceneOrder == SearcherSceneOrder.Alphabetic ?
                           scenesSorted.OrderBy(x => x.SceneVisibleName.ToLower()).ToList() :
                           scenesSorted.OrderBy(x => x.OrderNumber).ToList();

            var builder = new StringBuilder(GenerateHeader());

            foreach (var scene in scenesSorted)
            {
                builder.Append(MethodTemplate(menuItemTemplate + scene.SceneVisibleName, GenerateMethodName(), scene.SceneVisblePathInProject));
            }
            builder.Append(GenerateFooter());
            return(builder.ToString());
        }
コード例 #2
0
        private void GetPluginData()
        {
            var    seaercherFolder = AssetDatabase.FindAssets("SceneSearcher", null);
            string pluginPath      = "";

            foreach (var s in seaercherFolder)
            {
                var file = AssetDatabase.GUIDToAssetPath(s);
                if (file.Contains('.'))
                {
                    continue;
                }
                pluginPath = file;
            }
            pluginPath += "/";

            if (!Directory.Exists(pluginPath))
            {
                Debug.LogError("Directory " + pluginPath + " does not exist");
                return;
            }
            //Here all the services json files live.
            pluginPath = pluginPath + "Data/";
            var dataDirectory = !Directory.Exists(pluginPath) ?
                                Directory.CreateDirectory(pluginPath) :
                                new DirectoryInfo(pluginPath);

//			var files = dataDirectory.GetFiles("*.json");

            //Cache files paths
            _dataFilePath  = dataDirectory.FullName + DataFileName;
            _prefsFilePath = dataDirectory.FullName + PrefsFileName;

            //Parse data about plugin preferences
            if (File.Exists(dataDirectory.FullName + PrefsFileName))
            {
                var fileContents = File.ReadAllText(_prefsFilePath);
                if (!string.IsNullOrEmpty(fileContents))
                {
                    _preferences = JsonUtility.FromJson <SceneSearcherPreferences>(fileContents);
                }
            }
            if (_preferences == null)
            {
                _preferences = new SceneSearcherPreferences();
            }

            //Parse data about already cached scenes
            if (File.Exists(dataDirectory.FullName + DataFileName))
            {
                var fileContents = File.ReadAllText(_dataFilePath);
                if (!string.IsNullOrEmpty(fileContents))
                {
                    _scenesData = JsonUtility.FromJson <ScenesData>(fileContents);
                }
            }
            if (_scenesData == null)
            {
                _scenesData = new ScenesData();
            }
        }