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 arjunh · Sep 07, 2016 at 06:01 AM · unity 5gameobject

how to make an game object inactive at a particular time

i have a start camera in which their is an option "tap to start" when taped on screen the game begins. i have a game object added to the scene for this start camera. I need to make the game object deactivate when the the screen is tapped.Can u please suggest a method to do it..i am a beginner in unity.

Comment
Add comment · Show 2
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 arjunh · Sep 07, 2016 at 06:36 AM 0
Share

start camera is actually like a splash screen...like an intro to the game in which some animations are done...all those are inside the game object

avatar image arjunh · Sep 07, 2016 at 07:46 AM 0
Share

i have attached a script to game object

using UnityEngine; using System.Collections;

public class StartCameraBgScript : $$anonymous$$onoBehaviour {

 // Use this for initialization
 void Start () {

     gameObject.SetActive(false);
 
 }
 
 // Update is called once per frame
 void Update () {
     
 }

}

//but when i run the game ..from beginning itself the game object is in active...what i need is to make the game object inactive when the screen is touched (the gameobject is actually a start camera, like a splash screen)

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by arjunh · Sep 07, 2016 at 09:29 AM

             public class StartCameraBgScript : MonoBehaviour {
             bool Test = true;
            float Timer = 0.0f ;
                 // Use this for initialization
            void Start () {
 
 
              }
 
                // Update is called once per frame
                void Update () {
  
                            /* in  this foreach method  when the screen is touched the game begins and the game object automatically gets in active */
  foreach (Touch touch in Input.touches) {
      if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
      {
          gameObject.SetActive(false);
      }
  }
                      /* this method is given for testing in unity game player scince touch doesnot work (only mouse point),this is actually for testing purpose*/
  if (Test == true) {
      Timer += 1 * Time.deltaTime;
      if (Timer >= 5) 
      {
          coinMag = false;
          Timer = 0;
          gameObject.SetActive(false);
      }
  }
  
           }
           }
Comment
Add comment · 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
0

Answer by metalted · Sep 07, 2016 at 07:17 AM

You can try to use this method:

https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html

 public GameObject cameraHolder;
 
 void Start(){
 //Activate
 cameraHolder.SetActive(true);
 
 //Deactivate
 cameraHolder.SetActive(false);
 
 }
Comment
Add comment · Show 2 · 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 arjunh · Sep 07, 2016 at 07:38 AM 0
Share

using UnityEngine; using System.Collections;

public class ExampleClass : $$anonymous$$onoBehaviour { void Example() { gameObject.SetActive(false); } }

// my game object name is startcamera , how can i relate it in " gameObject.SetActive(false); "

avatar image arjunh · Sep 07, 2016 at 07:47 AM 0
Share

@metalted

i have attached a script to game object

using UnityEngine; using System.Collections;

public class StartCameraBgScript : $$anonymous$$onoBehaviour {

 // Use this for initialization
 void Start () {

     gameObject.SetActive(false);
 
 }
 
 // Update is called once per frame
 void Update () {
     
 }

}

//but when i run the game ..from beginning itself the game object is in active...what i need is to make the game object inactive when the screen is touched (the gameobject is actually a start camera, like a splash screen)

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

118 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

Related Questions

How can I create empty GameObject with name and determined RectTransform setteings within existing one? 2 Answers

how make object follow mouse cursor in 3d space 0 Answers

How to destroy only the collided instance of prefab and not the original one? 0 Answers

Cannot convert type `UnityEngine.GameObject[]' to `UnityEngine.GameObject' via a built-in conversion 1 Answer

How to Remove a Button after it has been pressed and executed it's script? 3 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