Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by ClanAlba · Dec 03, 2016 at 09:35 AM · c#build settingsgameplaylaunching

Why does my game only work after the second time I launch it?

I built my first game with Unity. I have tested it on an Android tablet and a Windows PC. I have the same problem on both platforms. After installing the game it never works on the initial launch, but every time after that it works smoothly without any faults. Is this a problem with Unity personal edition or should I look at my code somewhere? If it's my code, please give me any suggestion where I should start to look.

Comment
Add comment · Show 4
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 hexagonius · Dec 03, 2016 at 10:56 AM 1
Share

Does the error occur in editor too? Define "not working".

avatar image ClanAlba · Dec 04, 2016 at 10:48 AM 0
Share

Thanks, for your reply. There are 5 buttons on the first scene of my game( game level, controls, ball design , quit and game instructions). When I start the game after installing it the buttons dont work(flash as set but no action / response). But every time after that they work fine, it only happens on the initial start after installing the game. The same thing happens with android on a tablet, or windows on a pc. Actually it also happens in the unity editor when i try the game. Any advice would be appreciated,

avatar image hexagonius ClanAlba · Dec 04, 2016 at 09:17 PM 0
Share

if it's reproducible in the editor it's more easy.
next step would be to reproduce the error consistently. If you know when it occurs you can check why. pressing buttons is easy enough so you should check if the code behind it is executed. If it is, where is it different? are you checking done PlayerPrefs first written on the first run? etc

avatar image OusedGames · Dec 05, 2016 at 12:59 AM 0
Share

Hello, I had a problem with "Build and Run" option Everytime that Unity AUTO initialized a build it wouldn't work properly

  • I would recommend just build

  • and Run the game manually yourself - NOT "Build and Run"

hope it works

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ClanAlba · Dec 05, 2016 at 09:15 AM

Hi, Many thanks for the replies. It seems the problem is it's not loading the player prefs when the game runs for the first time. Obviously the first time the game runs there isn't any data to load, so how to I get round that problem. I have an void Awake script in another script but is doesnt seem to be checking this properly. Please help / advise again.

private void Awake() { instance = this; DontDestroyOnLoad (gameObject);

     if (PlayerPrefs.HasKey ("CurrentSkin")) 
     { // We had a previous session
         currentSkinIndex = PlayerPrefs.GetInt ("CurrentSkin");
         currency = PlayerPrefs.GetInt ("Currency");
         skinAvailability = PlayerPrefs.GetInt ("SkinAvailability");
     } else 
     {
         Save();
     }`
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 ClanAlba · Dec 05, 2016 at 10:45 AM 0
Share

$$anonymous$$any thanks for all your advice. I finally sorted out the problem with the buttons and finally showing the levels. I made a separate script for the button On Click Events and moved the level script into a private void Awake to find the information on the initial start when there is no data yet. Thank you all again,

No doubt I will be on here again with future games and coding.

Have your self a very $$anonymous$$erry $$anonymous$$

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

8 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Making a bubble level (not a game but work tool) 1 Answer

How can I adjust a different touch spots on the object 0 Answers

An OS design issue: File types associated with their appropriate programs 1 Answer


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