//Awake is always called before any Start functions void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); }
public void Configure(IApplicationBuilder app) { app.UseSignalR(routes => { routes.MapHub <ChatHubs>("/Chat"); }); app.UseDeveloperExceptionPage(); app.UseHttpsRedirection(); app.UseAuthentication(); app.UseDeveloperExceptionPage(); /* var supportedCultures = new[] * { * new CultureInfo("en"), * new CultureInfo("ru"), * new CultureInfo("de") * }; * app.UseRequestLocalization(new RequestLocalizationOptions * { * DefaultRequestCulture = new RequestCulture("en"), * SupportedCultures = supportedCultures, * SupportedUICultures = supportedCultures * });*/ var locOptions = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(locOptions.Value); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "default2", template: "{controller}/{action}/{id?}", constraints: new { id = new IntRouteConstraint() }, defaults: new { controller = "Phones", action = "Information" } ); routes.MapRoute( name: "ForContact", template: "{controller=Home}/{action=Contact}/{id?}"); routes.MapRoute( name: "ForIndex", template: "{controller=Phones}/{action=Index}/{id?}"); routes.MapRoute( name: "ForUsersIndex", template: "{controller=Users}/{action=Index}/{id?}"); routes.MapRoute( name: "ForUsersEdit", template: "{controller=Users}/{action=Edit}/{id?}"); routes.MapRoute( name: "ForHomePrivacy", template: "{controller=Home}/{action=Privacy}/{id?}"); routes.MapRoute( name: "ForRolesIndex", template: "{controller=Roles}/{action=Index}/{id?}"); routes.MapRoute( name: "ForRolesCreate", template: "{controller=Roles}/{action=Create}/{id?}"); routes.MapRoute( name: "ForRolesUserList", template: "{controller=Roles}/{action=UserList}/{id?}"); routes.MapRoute( name: "ForUsersCreate", template: "{controller=Users}/{action=Create}/{id?}"); }); using (var scope = app.ApplicationServices.CreateScope()) { AppDbContext context = scope.ServiceProvider.GetRequiredService <AppDbContext>(); ObjectsDB.Initial(context); } }