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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by KillMobil · Feb 10, 2015 at 01:04 PM · c#editoreditor-scriptingsceneview

2d mode through Editor Script

I am trying to set The Scene view to be in 2d mode with an editor script.

i can read the state on the sceneview with:

 SceneView.lastActiveSceneView.in2DMode;

not problem, no errors! But if i try to Set it i get the following error! Any clues?

 NullReferenceException: Object reference not set to an instance of an object
 UnityEditor.Tools.get_viewToolActive ()
 UnityEditor.Tools.get_viewTool ()
 UnityEditor.SceneView.set_in2DMode (Boolean value)


Thanks in advance!

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
3
Best Answer

Answer by highlyinteractive · Jul 27, 2015 at 12:18 PM

Just came across this solution:


    SceneView sv = SceneView.sceneViews[0] as SceneView;
    sv.in2DMode = true;

Obviously it's possible to have multiple scene views, so you might want to put this in a loop.

Comment
Add comment · Show 5 · 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 KillMobil · Jul 27, 2015 at 12:32 PM 0
Share

I still get the same error... Have you tried the code? did it work?

avatar image highlyinteractive · Jul 27, 2015 at 12:34 PM 0
Share

Yes, I have it working & I can toggle between 3D & 2D modes. What error are you getting?

avatar image KillMobil · Jul 27, 2015 at 12:41 PM 0
Share

Same Error As i have Above! Cant find anything about it tho... Any ideas what could be the issue?

NullReferenceException: Object reference not set to an instance of an object UnityEditor.Tools.get_viewToolActive () UnityEditor.Tools.get_viewTool () UnityEditor.SceneView.set_in2D$$anonymous$$ode (Boolean value)

avatar image highlyinteractive · Jul 27, 2015 at 12:50 PM 0
Share

Not sure - it looks like your instance of sceneview is null. What does SceneView.sceneViews.Count return?

avatar image KillMobil · Jul 27, 2015 at 01:07 PM 0
Share

Actual number of scenes... and the SceneView.sceneViews [0] returns (UnityEditor.SceneView)

I am working on Unity 4.6.5 so I tried the code in unity 5 and it works! So i guess its some sort of bug in Unity 4 maybe...

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

20 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

Related Questions

Handles Mouse Event Drag not working 1 Answer

Distribute terrain in zones 3 Answers

Stop a MonoBehavior from being addable as a script? 0 Answers

reflection propertyinfo.getvalue compiles fine but gives erros in editor 1 Answer

Working with Unity Editor 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