• 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 jester12272012 · Sep 14, 2021 at 09:52 AM · scripting problemunityeditorreferencehide

How do I make an unusable and hidden button until certain conditions are met ?

So I have been trying to get a "requirement" be set up for a button in order for it be usable and to appear, I am using doubles, and have tried to set it up with references and more here is the code, if anyone can help me or answer that would be nice.

also the error I got was about references, to be specific and I quote "NullreferenceException: Object reference not set to an instance of an object prestigebuttonrequisite.Update () (at assets/scripts/prestigebuttonrequisite.cs24) (pointing to my script I believe?)" sorry for not stating this sooner, hopefully this information should help resolve it.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class prestigebuttonrequisite : MonoBehaviour
 {
     // things that had to be set up ahead of time
     public GameObject Prestigescreenbutton;
     public GameObject PrestigeRequisiteobjectsource;
     public double coins;
     public double prestige_coins;
     // references
     public Idle_script_2 Game_manager;
 
     void Start()
     {
         Prestigescreenbutton.SetActive(false);
     }
 
 
     void Update()
     {
         Game_manager.coins = coins;
         Game_manager.prestigecoins = prestige_coins;
         if (Game_manager.coins < 1e+100)
         {
             Prestigescreenbutton.SetActive(true);
         }
 
         if (Game_manager.prestigecoins < 0)
         {
             Prestigescreenbutton.SetActive(true);
         }
     }
 }
 
Comment
Add comment · Show 3
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 Link0n3 · Sep 14, 2021 at 12:47 PM 0
Share

what is the error that you are getting?

avatar image Captain_Pineapple · Sep 14, 2021 at 04:38 PM 0
Share

what @Link0n3 says.


Please add more details. Why doubles? what values do the variables coins and prestigecoins have? why set it active in Update when coins/prestigecoins is smaller than zero or 1e+100?

avatar image jester12272012 · Sep 15, 2021 at 05:17 AM 0
Share

@Link0n3 I just updated for the error logs, sorry about not revealing it sooner, as for you @Captain_Pineapple I needed numbers well beyond 1e+100 (especially since I want a progression that isn't additive for my game that would result in extremely high numbers.) approximately around 1e+308 at least floats do not go high enough for the number from what I have seen, though the public double that I set up for this script is to test for references which that also failed I was attempting to use it as troubleshooting. The set to update was also something that I had tried as a solution, though I am really just a beginner with no idea what the hell I am doing to be honest

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Paum380 · Sep 14, 2021 at 04:53 PM

hello jester, i couldn't identify the problem, but from what i have in mind is, the script is attached to the same gameobject as the button, so you can might change the GameObject reference and just disable the button.

try this:

 //change this reference to...
 public GameObject Prestigescreenbutton;
 
 //this.
 public Button Prestigescreenbutton;












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 jester12272012 · Sep 15, 2021 at 09:32 PM 0
Share

This did not quite fix it. Turns out the problem has something to do with references at the moment.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

One Script Referred by Another Script used by Multiple Objects 0 Answers

Object reference not set to an instance of an object (Scripts calling objects which only exist in certain scenes) 1 Answer

Losing object reference 2 Answers

Respawn script not working. 2 Answers

Peculiar Bleed-through of Exposed References on different Timeline Tracks 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