Beispiel #1
0
        internal static void UpdateSceneValues(GenerateSetting setting, EditorBuildSettingsScene[] scenes)
        {
            if (!Settings.generateSceneValues)
            {
                return;
            }

            using (AssetEditing.Scope())
            {
                if (scenes == null)
                {
                    scenes = EditorBuildSettings.scenes;
                }

                var sceneIds   = new CSharpClass(setting.@namespace, "SceneId");
                var sceneNames = new CSharpClass(setting.@namespace, "SceneName");
                var scenePaths = new CSharpClass(setting.@namespace, "ScenePath");

                for (int i = 0; i < scenes.Length; i++)
                {
                    var scene     = scenes[i];
                    var sceneName = Path.GetFileNameWithoutExtension(scene.path);
                    var comment   = $"<para>{i}: {sceneName}</para>\n{scene.path}";
                    sceneIds.Fields.Add(new Variable("int", sceneName, i.ToString(), Modifier.Const, comment));
                    sceneNames.Fields.Add(new Variable("string", sceneName, sceneName.ToQuoted(), Modifier.Const, comment));
                    scenePaths.Fields.Add(new Variable("string", sceneName, scene.path.ToQuoted(), Modifier.Const, comment));
                }

                GenerateSourceCode(setting, "SceneValues.Generated", sceneIds, sceneNames, scenePaths);
            }
        }
Beispiel #2
0
        internal static void UpdateUnityConstants(GenerateSetting genSetting)
        {
            using (AssetEditing.Scope())
            {
                if (Settings.generateSortingLayerValues)
                {
                    CreateSortingLayerValues(genSetting);
                }

                if (Settings.generateLayerValues)
                {
                    CreateLayerValues(genSetting);
                }

                if (Settings.generateTagValues)
                {
                    CreateTagValues(genSetting);
                }
            }
        }