예제 #1
0
        static bool HasSceneEnumChanged()
        {
            var newSceneEnum  = EnumInfoHelper.GetSceneEnum(EditorBuildSettings.scenes);
            var allEnums      = enumInfoHelper.CreateInfoList();
            var prevSceneEnum = allEnums.Find(x => x.name == Names.sceneEnumName);

            return(newSceneEnum.values != prevSceneEnum.values);
        }
예제 #2
0
 /// <summary>
 ///     Update scenes enum if scenes have changed in build settings
 /// </summary>
 static void UpdateSceneEnum()
 {
     if (HasSceneEnumChanged())
     {
         Debug.Log("Android Performance Tuner: Scenes enum is updated");
         var newSceneEnum = EnumInfoHelper.GetSceneEnum(EditorBuildSettings.scenes);
         protoFile.AddEnum(newSceneEnum);
     }
 }
        /// <summary>
        ///     Update scenes enum if scenes have changed in build settings
        /// </summary>
        static void UpdateSceneEnum()
        {
            var allEnums      = enumInfoHelper.CreateInfoList();
            var newSceneEnum  = EnumInfoHelper.GetSceneEnum(EditorBuildSettings.scenes);
            var prevSceneEnum = allEnums.Find(x => x.name == Names.sceneEnumName);

            if (newSceneEnum.values == prevSceneEnum.values)
            {
                return;
            }
            Debug.Log("Android Performance Tuner: Scenes enum is updated");
            protoFile.AddEnum(newSceneEnum);
        }
        static Proto.FileInfo CreateProtoFile(DevDescriptor devDescriptor)
        {
            var protoFile = new Proto.FileInfo(devDescriptor.fileDescriptor);

            // Always add scene and loading state enum.
            protoFile.AddEnum(EnumInfoHelper.GetSceneEnum(EditorBuildSettings.scenes));
            protoFile.AddEnum(DefaultMessages.loadingStateEnum);

            protoFile.onUpdate += () =>
            {
                Action onFail = null;
                if (File.Exists(Paths.devProtoPath))
                {
                    var previousText = File.ReadAllText(Paths.devProtoPath);
                    onFail = () => { File.WriteAllText(Paths.devProtoPath, previousText); };
                }

                Directory.CreateDirectory(Path.GetDirectoryName(Paths.devProtoPath));
                File.WriteAllText(Paths.devProtoPath, protoFile.ToProtoString());
                if (!ProtocCompiler.GenerateProtoAndDesc() && onFail != null)
                {
                    onFail();
                }
                else
                {
                    AssetDatabase.Refresh();
                    areFidelityMessagesDirty = true;
                }
            };

            // If files do not exist yet, call OnUpdate to generate them (.proto, .descriptor and .cs).
            if (!File.Exists(Paths.devProtoPath) ||
                !File.Exists(Paths.devDescriptorPath) ||
                !FidelityBuilder.builder.valid)
            {
                protoFile.onUpdate();
            }

            return(protoFile);
        }