Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by SarperS · Sep 30, 2012 at 10:16 PM · cameraguieditorblenderevent

Blender like Camera Control Shortcuts

I'm trying to come up with an editor script that will let me change the scene view camera orientation with keypad keys (7 for top, 1 for front and 3 for right views) just like in Blender.

I'm able to get the right camera and get the correct keyboard events, but when I change the rotation of the scene view camera, nothing happens.

Is there a way to do this or better yet a class to access the top right gizmo in the scene view that we use to manipulate the camera orientation and render mode(perspective/orthographic)

Below is my code so far.

 using UnityEngine;
 using UnityEditor;
 
 [CustomEditor(typeof(Transform))]
 public class BlenderCamControl : Editor {
     public void OnSceneGUI() {
         //TODO If no transform selected, select first transform in hierarchy
 
         Event keyboardEvent = Event.current;
 
         if(keyboardEvent.isKey) {
             switch(keyboardEvent.keyCode) {
                 case KeyCode.Keypad1:
                     Debug.Log(Camera.current.transform.eulerAngles);
                     Camera.current.transform.rotation = Quaternion.Euler(new Vector3(0f, 180f, 0f));
                     break;
 
                 case KeyCode.Keypad3:
                     Camera.current.transform.rotation = Quaternion.Euler(new Vector3(0f, 270f, 0f));
                     break;
 
                 case KeyCode.Keypad7:
                     Camera.current.transform.rotation = Quaternion.Euler(new Vector3(90f, 0f, 0f));
                     break;
             }
         }
     }
 }
Comment
Add comment · Show 6
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 SarperS · Oct 01, 2012 at 07:09 AM 0
Share

I already know that, thanks, you can also right click on the middle cube to bring up a menu to select the orientation, but that's not the question.

avatar image SarperS · Oct 01, 2012 at 03:09 PM 0
Share

T27$$anonymous$$ thanks but that has nothing to do with what I'm trying to achieve.

avatar image SarperS · Oct 01, 2012 at 03:19 PM 0
Share

I'm not trying to draw a gizmo. Did you read the question?

avatar image SarperS · Oct 01, 2012 at 04:46 PM 0
Share

No I asked for a way to either rotate the scene camera with keyboard through it's transform or through the top right gizmo in the scene view that we use to manipulate the camera orientation and render mode(perspective/orthographic) via scripting. I don't want to access gizmos, just that handle on the top right which you use to change the scene view camera rotation.

avatar image SarperS · Oct 01, 2012 at 11:50 PM 0
Share

That's it, thanks a ton. I'll share the final version here as soon as I finish implementing all the keypad camera shortcuts of the Blender.

Convert your comment to an answer so I can select it as answered.

avatar image sayroar SarperS · Apr 11, 2016 at 01:15 AM 0
Share

Can you point me to the best method / steps for using this script? Thank you.

1 Reply

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

Answer by T27M · Oct 01, 2012 at 07:14 PM

Apologies , does this answer help. http://answers.unity3d.com/questions/142295/can-scene-camera-follow-the-object.html

Just like to add I'm only trying to help as I think this would be a neat feature considering how much I use blender.

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

12 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

Related Questions

UnityEvent draws debug variables in the inspector 0 Answers

Is there an event being fired off when the Inspector is being resized? 1 Answer

Notification of Game/Camera resize, in Editor. 0 Answers

How to add UnityEvent using Custom Inspector? 1 Answer

OnGUI Event 0 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