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 /
This question was closed Aug 07, 2017 at 08:19 AM by hexagonius for the following reason:

Question is off-topic or not relevant https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0029

avatar image
0
Question by Chappo935 · Aug 07, 2017 at 07:59 AM · error message

Assets/Scripts/GameManager.cs(24,33): error CS0029: Cannot implicitly convert type `bool' to `int'

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour {

 public int currentScore;
 public int highScore;
 public static int currentLevel = 0;
 public int unlockedLevel;
 public Color warningColorTimer;
 public Color defaultColorTimer;


 public Rect timerRect;
 public GUISkin skin;

 public float startTime;
 private string currentTime;
 
 void Start() {
     //DontDestroyOnLoad(gameObject);
     if(currentLevel = PlayerPrefs.GetInt("Level Completed") > 0) {
         PlayerPrefs.GetInt("Level Completed");
     } else {
         currentLevel = 0;
     }
     
 }

 void Update(){
     startTime -= Time.deltaTime;
     currentTime = string.Format("{0:0.00}", startTime);
     if(startTime <= 0) {
         startTime = 0;
         SceneManager.LoadScene(3);
     }
 }



 public void CompleteLevel() {
     if(currentLevel < 2) {
         currentLevel += 1;
         PlayerPrefs.SetInt("Level Completed", currentLevel);
         PlayerPrefs.SetInt("Level " + currentLevel.ToString() + " score", currentScore);

         SceneManager.LoadScene(currentLevel);
     } else {
         print("You won");
     }
 }

 void OnGUI() {
     GUI.skin = skin;
     if(startTime < 5f) {
         skin.GetStyle("Timer").normal.textColor = warningColorTimer;
     } else {
         skin.GetStyle("Timer").normal.textColor = defaultColorTimer;

     }
     GUI.Label(timerRect, currentTime, skin.GetStyle("Timer"));
 }

}

Comment
Add comment · Show 1
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 RisingDead_xTR · Aug 07, 2017 at 08:18 AM 0
Share

I can't understand what you mean by " if (currentLevel = PlayerPrefs.GetInt("Level Completed") > 0)". Do you want to check if currentLevel is equals PlayerPrefs.GetInt("Level Completed") and PlayerPrefs.GetInt("Level Completed") is greater than 0?

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

68 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 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 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 avatar image avatar image

Related Questions

error info when Create Object ? 0 Answers

Chrome 56 WebGL error 1 Answer

Unreseolved NullReferenceException: Object reference not set to an instance of an object 2 Answers

My dagger attached to an enemy won't detect it's parent's Ai Script 1 Answer

How to fix error cs1518 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