Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
avatar image
0
Question by Giantbean · Jan 02, 2014 at 11:15 PM · cameragetcomponentpausedisable

Secoundary/GUI camera not pausing/disabeling.

I need to Disable one script on two objects from a script on a third object.

I have a Script on my main camera and on a GUI camera that makes them mimics the movement in the main window (like a Maya or Unitys main view and view cube). My script disables the camera in the main view when I want but the mini-map view cube keeps moving.

Here is a summery of what I have:

 private float waitTime = 0.75f; //wait time befor reacting to mouse hold
 private float downTime; //internal time from when the key is pressed
 private bool isHandled = false; //toggle the mouse hold event on and off
 GameObject Cam1;
 GameObject Cam2;
 FreeObjectRotationCam frc1;
 FreeObjectRotationCam frc2;
 
     //link the cameras and movment script for mark up menue pauseing. 
     void Awake(){
         Cam1 = GameObject.Find("Main Camera");
         Cam2 = GameObject.Find("GUICamera");
         frc1 = Cam1.GetComponent<FreeObjectRotationCam>() as FreeObjectRotationCam;
         frc2 = Cam2.GetComponent<FreeObjectRotationCam>() as FreeObjectRotationCam;
     }

Then when I hold the mouse down I disable the script.

 void OnMouseDrag(){
         
         if((Time.time > downTime + waitTime) && !isHandled){
             isHandled = true;// reset the timer for the next button press
 
             //Disable the Camera mouse movement.
             frc1.enabled=false;
             frc2.enabled=false;
 }

The frc1.enabled = true/false works fine but the frc2 is doing nothing. Any ideas how I can make the script turn off on both cameras? I tried frc1.enabled = !frc1.enabled to toggle but that didn't work.

My code is based on the answer here: http://answers.unity3d.com/questions/553324/problem-in-calling-scripts.html

Can I not call the same script twice even though it is on a different object?

When I turn off frc2 first it pauses the view cube and not the main window.

If this question needs any clarification let me know and I will edit as needed.

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

1 Reply

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

Answer by Giantbean · Jan 06, 2014 at 05:25 PM

I got the code working. The above code is fine.

I had

 //re-enable Camera mouse movement.
 void LateUpdate(){
     if (Input.GetMouseButtonDown(0)&& isHandled)
         frc1.enabled=true;
         frc2.enabled=true;
 }

which I replaced with

 void OnMouseUp(){
     frc1.enabled=true;
     frc2.enabled=true;
 }

and now it is working.

I think I may have had something commented out that shouldn't have been or some syntax error that mono develop didn't catch.

But its working now so its all good. I hope this post helps someone else in need.

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

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

18 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

Related Questions

First Person Camera disabling 1 Answer

script from another 1 Answer

mars get camera position 0 Answers

how can I disable all camera movements trough GUI? 2 Answers

Turn Off/on culling mask by script? 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