Exemple #1
0
        //[MenuItem("Tools/Runtime SaveLoad/Persistent Classes/Build Type Model")]
        private static void BuildTypeModel()
        {
            //Removal of RTSLTypeModel.dll created by previous version of RTE
            File.Delete(Application.dataPath + RTSLPath.UserRoot + "/" + RTSLPath.TypeModel + ".dll");

            EditorUtility.DisplayProgressBar("Build", "Building Type Model...", 0.66f);
            RuntimeTypeModel model = TypeModelCreator.Create();

            model.Compile(new RuntimeTypeModel.CompilerOptions()
            {
                OutputPath = TypeModelDll, TypeName = RTSLPath.TypeModel
            });

            string srcPath = Application.dataPath.Remove(Application.dataPath.LastIndexOf("Assets")) + TypeModelDll;
            string dstPath = Application.dataPath + RTSLPath.UserRoot + "/" + TypeModelDll;

            Debug.LogFormat("Done! Move {0} to {1} ...", srcPath, dstPath);

            StringBuilder sb = new StringBuilder();

            foreach (BuildTarget target in Enum.GetValues(typeof(BuildTarget)))
            {
                sb.AppendFormat(LinkFileAssemblyName, target);
            }
            File.WriteAllText(Application.dataPath + RTSLPath.UserRoot + "/link.xml", string.Format(LinkFileTemplate, sb.ToString()));
            File.Delete(dstPath);
            File.Move(srcPath, dstPath);

            EditorPrefs.SetBool("RTSL_UpdateTypeModelImportSettings", true);
            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
        }
Exemple #2
0
        private static void BuildTypeModel()
        {
            RuntimeTypeModel model   = TypeModelCreator.Create();
            string           dllName = RTSLPath.TypeModelDll;

            model.Compile(new RuntimeTypeModel.CompilerOptions()
            {
                OutputPath = dllName, TypeName = "RTSLTypeModel"
            });

            string srcPath = Application.dataPath.Remove(Application.dataPath.LastIndexOf("Assets")) + dllName;
            string dstPath = Application.dataPath + RTSLPath.UserRoot + "/" + dllName;

            Debug.LogFormat("Done! Move {0} to {1} ...", srcPath, dstPath);
            File.Delete(dstPath);
            File.Move(srcPath, dstPath);

            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);

            PluginImporter importer = AssetImporter.GetAtPath("Assets" + RTSLPath.UserRoot + "/" + dllName) as PluginImporter;

            importer.SetCompatibleWithAnyPlatform(true);
            importer.SetExcludeEditorFromAnyPlatform(true);
            importer.SaveAndReimport();
        }
        static ProtobufSerializer()
        {
#if !UNITY_EDITOR
            Assembly typeModelAssembly = AppDomain.CurrentDomain.GetAssemblies().Where(asm => asm.FullName.Contains("RTSLTypeModel")).FirstOrDefault();
            Type     type = null;
            if (typeModelAssembly != null)
            {
                type = typeModelAssembly.GetTypes().Where(t => t.Name.Contains("RTSLTypeModel")).FirstOrDefault();
            }

            if (type != null)
            {
                model = Activator.CreateInstance(type) as TypeModel;
            }

            if (model == null)
            {
                UnityEngine.Debug.LogError("RTSLTypeModel was not found. Please build type model using the Build All button available through the Tools->Runtime SaveLoad->Config menu item in Unity Editor.");
            }
#endif
            if (model == null)
            {
                model = TypeModelCreator.Create();
            }

            model.DynamicTypeFormatting += (sender, args) =>
            {
                if (args.FormattedName == null)
                {
                    return;
                }

                if (Type.GetType(args.FormattedName) == null)
                {
                    args.Type = typeof(NilContainer);
                }
            };

            #if UNITY_EDITOR
            RuntimeTypeModel runtimeTypeModel = model as RuntimeTypeModel;
            if (runtimeTypeModel != null)
            {
                runtimeTypeModel.CompileInPlace();
            }
            #endif
        }
Exemple #4
0
        private static void BuildTypeModel()
        {
            EditorUtility.DisplayProgressBar("Build", "Building Type Model...", 0.66f);
            RuntimeTypeModel model = TypeModelCreator.Create();

            model.Compile(new RuntimeTypeModel.CompilerOptions()
            {
                OutputPath = RTSLPath.TypeModelDll, TypeName = "RTSLTypeModel"
            });

            string srcPath = Application.dataPath.Remove(Application.dataPath.LastIndexOf("Assets")) + RTSLPath.TypeModelDll;
            string dstPath = Application.dataPath + RTSLPath.UserRoot + "/" + RTSLPath.TypeModelDll;

            Debug.LogFormat("Done! Move {0} to {1} ...", srcPath, dstPath);
            File.Delete(dstPath);
            File.Move(srcPath, dstPath);

            EditorPrefs.SetBool("RTSL_UpdateTypeModelImportSettings", true);
            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
        }
        static ProtobufSerializer()
        {
#if !UNITY_EDITOR
            Type type = Type.GetType("RTSLTypeModel, RTSLTypeModel");

            if (type != null)
            {
                model = Activator.CreateInstance(type) as TypeModel;
            }

            if (model == null)
            {
                UnityEngine.Debug.LogError("RTSLTypeModel.dll was not found. Please build type model using Tools->Runtime SaveLoad->Build All menu item from Unity Editor");
            }
#endif
            if (model == null)
            {
                model = TypeModelCreator.Create();
            }

            model.DynamicTypeFormatting += (sender, args) =>
            {
                if (args.FormattedName == null)
                {
                    return;
                }

                if (Type.GetType(args.FormattedName) == null)
                {
                    args.Type = typeof(NilContainer);
                }
            };

            #if UNITY_EDITOR
            RuntimeTypeModel runtimeTypeModel = model as RuntimeTypeModel;
            if (runtimeTypeModel != null)
            {
                runtimeTypeModel.CompileInPlace();
            }
            #endif
        }