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 /
avatar image
2
Question by Joe 2 · Mar 20, 2010 at 11:14 PM · cameraeditoreditor-scripting

How can I simulate the "f" hotkey in the editor?

I want to write a script to add a menu item that, when clicked, brings the main character into focus in the Scene view. So far, I can't seem to get it or find any resources on how to change the scene view's camera position/rotation.

How can I set the position/rotation of the scene view's camera in the editor at design-time?

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

4 Replies

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

Answer by noahmjohnson · Mar 09, 2011 at 08:21 PM

According to this tread:

http://forum.unity3d.com/threads/54411-Focusing-the-editor-s-Scene-camera-on-an-object-position?highlight=scene+camera

You can use:

SceneView.lastActiveSceneView.FrameSelected()

It works for me, although because it is undocumented, it is subject to not work or change.

I have mine set up as an editor script button:

if(GUILayout.Button("Frame Camera", GUILayout.Width(120)))
{
SceneView.lastActiveSceneView.FrameSelected()
}

Hope this helps!

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
1

Answer by ThomLaurent · Jan 28, 2017 at 01:24 PM

An alternative to @noahmjohnson 's answer:

SceneView.lastActiveSceneView.SendEvent(EditorGUIUtility.CommandEvent("FrameSelected"));

For the other editor commands, refer to their name in the Edit menu of the Unity Editor window (triming spaces).

See EditorGUIUtility.CommandEvent and EditorWindow.SendEvent

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 davebuchhofer · Mar 21, 2010 at 02:35 AM

Try Jaap's answer to my similar question earlier: http://answers.unity3d.com/questions/5875/how-can-i-mimic-the-frame-selected-f-camera-move-zoom-extents-zoom-to-fit

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 Joe 2 · Mar 24, 2010 at 02:16 AM 0
Share

Is there a way to run code like this at design-time?

avatar image
0

Answer by Joe 2 · Mar 28, 2010 at 08:27 PM

You can't at design-time, only run-time.

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

1 Person is following this question.

avatar image

Related Questions

How can I preserve static object/data between editor and play? 2 Answers

HideFlags on children of visible objects. 3 Answers

Unity Editor Scripts: GameObject Added / Removed Event? 1 Answer

How to record the entire game and user behaviour for a research project? 1 Answer

problem with the digits of my timer 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