• 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
Question by EvilTeliportist · Dec 12, 2016 at 07:50 AM · setactive

SetActive Not Working on Deactivated Objects and Imput.GetKeyDown isnt working either

I have some script that is supposed to make map sections unlocked when I press n. Then, if I press m, the map will come up, if active. For some reason, my input.getkeydown for the letter n to make the parts active does not work. T$$anonymous$$s is because the gameobjects are inactive. Is there a way I can do t$$anonymous$$s simply?

 using UnityEngine;
 using System.Collections;
 
 public class Maps : MonoBehaviour
 {
 
     public GameObject topLeft;
     public GameObject topCenter;
     public GameObject topRight;
     public GameObject midLeft;
     public GameObject midCenter;
     public GameObject midRight;
     public GameObject bottomLeft;
     public GameObject bottomCenter;
     public GameObject bottomRight;
     public bool menuUp;
 
     public bool topLeftUnlocked;
     public bool topCenterUnlocked;
     public bool topRightUnlocked;
     public bool midLeftUnlocked;
     public bool midCenterUnlocked;
     public bool midRightUnlocked;
     public bool bottomLeftUnlocked;
     public bool bottomCenterUnlocked;
     public bool bottomRightUnlocked;
 
 
     // Use t$$anonymous$$s for initialization
     void Start()
     {
 
         topLeft.SetActive(false);
         topCenter.SetActive(false);
         topRight.SetActive(false);
         midCenter.SetActive(false);
         midLeft.SetActive(false);
         midRight.SetActive(false);
         bottomCenter.SetActive(false);
         bottomRight.SetActive(false);
         bottomLeft.SetActive(false);
 
         menuUp = false;
 
         topLeftUnlocked = false;
         topRightUnlocked = false;
         topCenterUnlocked = false;
         midCenterUnlocked = false;
         midRightUnlocked = false;
         midLeftUnlocked = false;
         bottomCenterUnlocked = false;
         bottomRightUnlocked = false;
         bottomLeftUnlocked = false;
 
     }
 
     // Update is called once per frame
     void Update()
     {
 
         if (Input.GetKeyDown("m"))
         {
             if (menuUp == false)
             {
                 menuUp = true;
             }
             else
             {
                 menuUp = false;
             }
 
             //menuUp = true
 
             if (menuUp == true)
             {
                 if (topLeftUnlocked == true)
                 {
                     topLeft.SetActive(true);
                 }
 
                 if (topCenterUnlocked == true)
                 {
                     topCenter.SetActive(true);
                 }
 
                 if (topRightUnlocked == true)
                 {
                     topRight.SetActive(true);
                 }
 
                 if (midLeftUnlocked == true)
                 {
                     midLeft.SetActive(true);
                 }
 
                 if (midCenterUnlocked == true)
                 {
                     midCenter.SetActive(true);
                 }
 
                 if (midRightUnlocked == true)
                 {
                     midRight.SetActive(true);
                 }
 
                 if (bottomLeftUnlocked == true)
                 {
                     bottomLeft.SetActive(true);
                 }
 
                 if (bottomCenterUnlocked == true)
                 {
                     bottomCenter.SetActive(true);
                 }
 
                 if (bottomRightUnlocked == true)
                 {
                     bottomRight.SetActive(true);
                 }
 
                 //making them true
             }
                 if (Input.GetKeyDown("n"))
                 {
                     topCenterUnlocked = true;
                     topLeftUnlocked = true;
                     topRightUnlocked = true;
                     midCenterUnlocked = true;
                     midLeftUnlocked = true;
                     midRightUnlocked = true;
                     bottomCenterUnlocked = true;
                     bottomLeftUnlocked = true;
                     bottomRightUnlocked = true;
                 } else {
 
                 }
 
             
 
         }
     }
 }
Comment

People who like this

0 Show 0
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.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

physics.OverlapSphere colliders 1 Answer

Does inactive Objects eat up Performance? 1 Answer

How to make a gameObject disappear when a mouse hovers and reappear when the mouse leaves? 1 Answer

Efficient Way to Create/Destroy and Switch Between Player GameObjects 1 Answer

Select Car - Multiple prefabs 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