Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-1
Question by mbivol10 · Nov 27, 2013 at 10:53 PM · databaseloginstatsswitch scenes

How to change from login scene to character costum scene ?

Ok what im trying to say is that ive a login page where it uses database , and a function if (w.text == "login-SUCCESS") { Application.LoadLevel(1); but as the new scene opens up i want it to show welcome user that has just logged in , with database please help thanks !

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Starwalker · Nov 27, 2013 at 11:10 PM 0
Share

Application.LoadLevel

This parameter takes a string, that is the scene name, you can have multiple scene's in your project, on your login scene call it, "SceneLogin" and when the login is authenticated then use the above to load "Scene$$anonymous$$ain" or something, on Scene$$anonymous$$ain you can make welcome UI.

avatar image karljj1 · Nov 28, 2013 at 07:18 PM 0
Share

If you want to keep some data between the scenes you could also use Application.LoadLevelAdditive to keep the same scene and just append to it or Object.DontDestroyOnLoad to keep an object alive between scene transitions.

5 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Agemennon · Nov 28, 2013 at 12:01 AM

I might be making assumptions here, but it seems your issue is that you want to carry information from one scene into the next.

You probably want to look into Object.DontDestroyOnLoad

Essentially you want to call this on a GameObject with a script which can tell your welcome panel to say things after your new scene loads.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by diegzumillo · Nov 28, 2013 at 12:03 AM

I don't know what is the best approach here, but you can have the username stored in the playerprefs, so it's accessible on all scenes. You can also store this and whatever other information you find relevant in a gameobject that isn't destroyed on loading a new level. You do that by using DontDestroyOnLoad (transform.gameObject);

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by mbivol10 · Nov 28, 2013 at 11:04 AM

thanks i do get the part of saving the object but i need to know how to get the name out of the database on load , a script that will load the name to the player prefab from the database after login thanks :) of course im researching but the scripts that are on the internet that i have researched so far do not load to the player prefab from the actual database if anyone knows please leave the script here thanks :)

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Agemennon · Nov 28, 2013 at 03:21 PM 0
Share

When you initially asked your question you implied that you already had a database connection script.

Since its is unlikely that you'll find someone here that will just outright write a script for you like that, you're probably want to look into some tutorials that involve using whatever database you're trying to use with C# prior to interfacing that with Unity.

avatar image diegzumillo · Nov 28, 2013 at 04:30 PM 0
Share

It seemed implied. (And you just made a comment using the answer system :P)

avatar image
0

Answer by anderas · Nov 28, 2013 at 01:04 PM

If I understand your question correctly, you log the user in on the main menu scene, load another scene and want to access the data from the database, right? I have a similar situation in my application.

I solved it this way:

  1. Create a GameObject ("DataContainer" in the following points)

  2. Attach a script that calls DontDestroyOnLoad(gameObject) to this object

  3. Attach another script that basically only consists of public fields for the user data to the DataContainer object

  4. After you logged in the user, put all relevant data into the script from the last point.

  5. Load the next scene using Application.LoadLevel

  6. Get the data from the DataContainer object in a script from the new scene/level and draw your welcome screen

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mbivol10 · Nov 28, 2013 at 07:15 PM 0
Share

Attach another script that basically only consists of public fields for the user data to the DataContainer object After you logged in the user, put all relevant data into the script from the last point. well whats what im stuck on the script i use is working good you can find it here http://lunerisonline.host56.com/ the reason i put login and register in css is for youto be able to read the files online because in php will just not be possible to read but anyway: "it but the consists of public fields and put all data with field" , that is really what i don't get its just don't understand , but i will try the part where the data is saved to the game object that part is the question , how do i do save that data , first i have a database called account and it has a table that consists of : id,user,name,cash,level,pass and i would like to take the data and put into the object that does not get destroyed yes i got the script of not to destroy and im going to put it into an empty game object now but please help me with the part where it takes from the database and puts into the game object into the new level(scene) thanks :)

avatar image mbivol10 · Nov 28, 2013 at 07:44 PM 0
Share

thanks anyway i think i found what i was really looking for Here :) step by step of what i was looking for what ive got to do next is a garage with equip and buy which i already have but not the items , especially loaded from the database ill have to get used to database coding thats what i have so far of what my next thing is going to do look like :) thanks :) alt text

![alt text][2]

untitled.png (443.7 kB)
avatar image
0

Answer by palalopea · Dec 07, 2017 at 07:18 AM

can someone share the script when we use DontDestroyOnLoad?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jchester07 · Dec 07, 2017 at 07:52 AM 0
Share

The Script

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Connecting to access database via C# 1 Answer

Making a user database with photon? 0 Answers

Firebase Saves and retrieves data perfectly on editor, but does't work on mobiles 0 Answers

Want more information about Connect Local database 0 Answers

tris in Rendering Statistics Window 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges