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 /
  • Help Room /
avatar image
0
Question by GNPhoque · Jun 12, 2017 at 06:44 AM · error messagebegginerprotection

UI elements not accessible due to protection level

I've been struggling with this error for a few days now and can't find a way out ... I've searched on the forum and found that this error should be caused by the property being private but in my case i switched everything to public and still no good. I've tried inserting constructors and whatnot , now I need your help please.

Btw it's a clicker project I started to learn how to use Unity

Main File-----------------------------------------------------------------------------------------------------------

 using UnityEngine;
 using System.Collections;
 
 public class InitScript : MonoBehaviour {    
 
     public UnityEngine.UI.Text goldText, BonusInfoText, GPSText;
     public float gold = 0, GPC = 0, GPS = 0;
     public GPCUpgrade pioche = new GPCUpgrade(){name="Pioche",baseCost=100,cost=100,bonusPower=1, level=0};
     public GPCUpgrade chariot = new GPCUpgrade(){name="Chariot",baseCost=100,cost=100,bonusPower=1, level=0};
     public GPCUpgrade dynamite = new GPCUpgrade(){name="Dynamite",baseCost=100,cost=100,bonusPower=1, level=0};
     //public GPSUpgrade mineurs = new GPSUpgrade("Mineur",15,15,0.1f,0);
     //public GPSUpgrade mineurs = new GPSUpgrade(){name="Mineur",baseCost=15,cost=15,bonusPower=0.1f, level=0};
 
     void Start () {        
         InvokeRepeating ("Tick", 1.0f, 1.0f);    
     }
 
     void Update () {
         pioche.bonusPower = 0;
         goldText.text = "Gold\n" + Mathf.Floor(gold);
         BonusInfoText.text = "Gold par click : " + GPC+ "\nGold par seconde : " + GPS;
 
     }
 
     private void Tick(){
         GPS = (Mathf.Round (GPS*10))/10;
         gold += GPS;
     }
 
     private void GoldClick(float gold, float GPC){
         gold+= GPC;
     }
 
     private void GPCClick(float gold, float GPC){
         
     }
 
     private void GPSClick(float gold, float GPS){
 
     }
 
 }
 


Class File ------------------------------------------------------------------------------------------------------

 using UnityEngine;
 using System.Collections;
 
 public class GPSUpgrade : MonoBehaviour {
 
     public string nom = "";
     public int baseCost = 0;
     public int cost = 0;
     public float bonusPower = 0;
     public int level = 0;
     public UnityEngine.UI.Button btn = new UnityEngine.UI.Button ();
     public UnityEngine.UI.Text GPSText=new UnityEngine.UI.Text(){text=nom + "\t\t\t LVL " + level + "\nCost : " 
                                                             + cost+ "gold \nGain ; "+ bonusPower + "GPS"};
     
     /*public GPSUpgrade(){
 
     string nom = "";
     int baseCost = 0;
     int cost = 0;
     float bonusPower = 0;
     int level = 0;
     UnityEngine.UI.Button btn = new UnityEngine.UI.Button ();
     UnityEngine.UI.Text GPSText=new UnityEngine.UI.Text(){text=nom + "\t\t\t LVL " + level + "\nCost : " 
                                                             + cost+ "gold \nGain ; "+ bonusPower + "GPS"};
     }
 
     public GPSUpgrade(string vnom,int vbaseCost, int vcost, float vbonusPower, int vlevel){
         string nom = vnom;
         int baseCost = vbaseCost;
         int cost = vcost;
         float bonusPower = vbonusPower;
         int level = vlevel;
         UnityEngine.UI.Button btn = new UnityEngine.UI.Button ();
         UnityEngine.UI.Text GPSText=new UnityEngine.UI.Text(){text=nom + "\t\t\t LVL " + level + "\nCost : " 
                                                                 + cost+ "gold \nGain ; "+ bonusPower + "GPS"};
     }
     */    
     public void Clicked(float gold, float GPS){
 
         if (gold >= cost) {
             gold -= cost;
             GPS += bonusPower;
             level++;
             cost = Mathf.FloorToInt(baseCost * Mathf.Pow(1.15f,level));
         }
     }
 }
 

 


alt text

capture.png (19.6 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

107 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 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

hello! Im a begginer trying to solve this. OverflowException: Number overflow. CreateGame..ctor () (at Assets/scripts/CreateGame.cs:28) 0 Answers

UI elements not accessible due to protection level 0 Answers

Why do i get an error ? please help i've stuck for 20 min 1 Answer

Simple error but I'm just a begginer and cant figure this out, due to outdated API. 1 Answer

weird Object reference not set to an instance of an object error, help 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