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
1
Question by jimfleming · Jun 01, 2014 at 05:18 PM · c#editorprojectreflectionwizard

Programmatically display Project Wizard

Is there a way to display to project wizard from "Edit/New Project..." or "Edit/Open Project..." programmatically? Making an editor extension to automate some things.

EDIT: I should note that I've looked everywhere I can think of using reflection. Searching for methods and types with the names "Project", "Wizard", "Open" or "New" without success.

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

Answer by vexe · Jun 14, 2014 at 12:24 AM

This doesn't answer you, but might give you some ideas...

I couldn't find it too. But if you look at its GUI, it looks like a Winform or something which means it's not implemented in Unity's managed dlls. As opposed to the BuildPlayerWindow which is using Unity's editor API. Analyzing the usage of the show methods in BuildPlayerWindow lead to nowhere (using ILSpy) which probably means it's used from unmanaged land. I looked at BuildPlayerWindow cause I thought if I get close to one of the File/ items I could get close to "New project" - but no... I also managed to find "Save scene" - in EditorApplication.SaveScene

My first reaction when I read your question is to use EditorApplication.ExecuteMenuItem with "File/New Project" as a parameter. But it didn't work of course cause they're not really menu items...

I then turned to (a hack) sending an Alt+F+N+Enter key combination. Cause, as you might well know, if you press Alt+F you're in the "File" menu, now press N to go "New Project" and Enter/Return to press it. I couldn't do it right though, I first tried getting the current focused window and doing a SendEvent to it (cause the combo works from any editor window):

 var focused = EditorWindow.focusedWindow;
 
 // I tried creating the alt event in many ways, non succeeded:
 var alt1 = new Event
 {
     type = EventType.KeyDown | EventType.KeyUp,
     modifiers = EventModifiers.Alt,
     alt = true
 };
 var alt2 = new Event
 {
     type = EventType.KeyDown,
     modifiers = EventModifiers.Alt,
     alt = true
 };
 var alt3 = new Event
 {
     type = EventType.KeyDown,
     modifiers = EventModifiers.Alt,
     alt = true
 };
 var alt4 = new Event
 {
     type = EventType.KeyDown,
     keyCode = KeyCode.LeftAlt
 };
 
 focused.SendEvent(any of the previous alts);


I gave up on using SendEvent, and turned into WinAPI and using my NativeCalls class. I managed to get Alt+F sent, but not N and then Return.

 NativeCalls.SendKey(NativeCalls.VirtualKeyCode.ALT);
 NativeCalls.SendKey(NativeCalls.VirtualKeyCode.KEY_F);

I linked you the code so maybe you can get it right.

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 jimfleming · Jun 14, 2014 at 06:48 PM 0
Share

That sounds like an excellent starting place, thanks!

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

22 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

Related Questions

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

Reflection only works in Play Mode? 1 Answer

how to save instance of class trough editor 1 Answer

How to open an Editor Window by using the MethodInfo.Invoke function ? 1 Answer

Multiple Cars not working 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