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 KarlH · May 08, 2011 at 04:38 PM · scene-loadingguitextdontdestroyonload

DontDestroyOnLoad question

ok. i have a GUIText object with a score script attached and also a script shown below (dont destroy on load)

function Awake () {

DontDestroyOnLoad (this);

}

so my text and score will carry over to a new scene when its time up in my level. im just wondering how to move the position of the GUI text in my new scene without it effecting the position of it in the first scene. at the min the score is displayed at the top left hand side of the screen when playing, i would like it moved to around the centre of the screen on the new scene. i just dont have a clue where to start.

I appreciate any help

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by GesterX · May 08, 2011 at 04:42 PM

You could do this with a gameobject you name "LevelManager". The attach a "levelOne" script to it which finds the GUIText object and moves it in the Start() function. Simply have a different script for each level you want to move it in (or detect the level and move it).

So your game will do this:

  1. Load the new level
  2. Not destroy the GUIText
  3. Move the GUIText

This will all happen so fast you won't see it.

Alternatively you could use Application.loadedLevel to detect what level is loaded in a script attached to the GUIText itself and move it depending on what Application.loadedLevel returns.

Comment
Add comment · Show 3 · 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 KarlH · May 08, 2011 at 04:57 PM 0
Share

thanks, this seems like a very simple method. does the awake function run before the start function then?

avatar image GesterX · May 08, 2011 at 05:00 PM 0
Share

Yes it does :) No worries

avatar image KarlH · May 08, 2011 at 05:26 PM 0
Share

im stuck already >.< i think im on the right track though. i have

function Start () { GameObject.Find("$$anonymous$$eepScore").transform.position = Vector3(-615, 295, 0); }

is this right? because iv tried it like this and i cant see the text. im not sure if the x, y, z coords are totally out or this is the totally wrong script for doing it :/

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

No one has followed this question yet.

Related Questions

Canvas will only appear on the game screen when its child of a new loaded scene canvas 1 Answer

NavMeshAgent (with DoNotDestroyOnLoad) Not Work After LoadScene; Transform Locked 0 Answers

DontDestroyOnLoad on disabled object doesn't work? 1 Answer

When I reload my Scene, nothing works. I think it's because of a dontDestroyOnLoad gameObject 0 Answers

DontDestroyOnLoad, where is my error? 2 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