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
1
Question by AntonStruyk · Oct 18, 2011 at 08:08 PM · editordialog

Custom dialog in editor

How can I show a custom dialog in the editor?

I have a dialog I want to make, that contains some checkboxes and some other random controls. I want to show it to the user when they click on a button (in a custom inspector I have already made) in order to choose what to do.

How would I go about doing this in Unity? I can only find dialog calls that are simple message boxes...

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

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by turbanov · Dec 27, 2017 at 11:09 AM

I would strongly recommend using a custom EditorWindow for that purpose. The suggested ScriptableWizard is kinda ugly and gimmicky. It doesn't provide any substantial benefit, including no modality support.

Create your own window like this, and it will do just fine:

     var window = GetWindow<MyWizardWindow>(utility: true, title: "Create New Object", focus: true);
     window.ShowUtility();

Your GUI logic then has to be like this:

     protected virtual void OnGUI()
     {
         _Error = null;
         EditorGUILayout.PrefixLabel("Name");
         _Name = EditorGUILayout.TextField(_Name);
         if (!IsValid(this._Name))
             _Error = "The name is invalid";

         if (!string.IsNullOrEmpty(_Error))
             EditorGUILayout.HelpBox(_Error, MessageType.Error);

         GUILayout.FlexibleSpace();

         EditorGUILayout.BeginHorizontal();

         if (GUILayout.Button("Cancel"))
         {
             Cancel();
         }

         EditorGUI.BeginDisabledGroup(!string.IsNullOrEmpty(_Error));
         if (GUILayout.Button("Create"))
         {
             Create();
         }
         EditorGUI.EndDisabledGroup();

         EditorGUILayout.EndHorizontal();
     }
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
2

Answer by jahroy · Oct 19, 2011 at 12:58 AM

Are you looking for ScriptableWizards?

They're like popup windows that you can add controls to.

They allow you to set a bunch of values (even drag and drop game objects) and then execute code when different buttons are pressed.

Comment
Add comment · Show 2 · 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 AntonStruyk · Oct 20, 2011 at 02:15 PM 0
Share

I think I can do what I need with a one-pane wizard. Thanks!

avatar image turbanov · Dec 27, 2017 at 10:16 AM 0
Share

This seems to be the same as window.ShowUtility();, really, with some quirks and specialties. Unfortunately it still has no modality status.

avatar image
-1

Answer by Bunny83 · Oct 18, 2011 at 11:50 PM

Unfortunately (AFAIK) there's no way to display an editor window as a modal window. The only thing that comes with Unity are the simple dialg boxes you've already found (EditorUtility.DisplayDialogComplex).

Well, in a multitasking environment modal windows are evil, Just in some rare cases they would be helpful. Just check if you really need it modal. The user would be pleased when he still can select other things to look up some settings or whatever...

A more or less related question:
http://answers.unity3d.com/questions/139677/how-to-make-a-modal-dialog.html

Comment
Add comment · Show 2 · 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 yoyo · Nov 17, 2012 at 01:04 AM 0
Share

Asset$$anonymous$$odificationProcess.OnWillSaveAssets is a good example of a time when you might need a modal dialog. I want to present the user with various options for what to do (overwrite, skip, skip remaining, get SVN lock, etc.) and it needs to be modal because the method has to return an array of strings immediately.

avatar image LightStriker · Sep 16, 2013 at 08:03 PM 0
Share

Saying they are evil is rather false. There's many situation where the user wants to perform complex operation that are done steps by steps and where changing the scene it is performed on can corrupt it. Unity was never designed with real productivity in $$anonymous$$d. Any time I try to code tools or editors that would automatize the most redundant actions a user has to perform, I hit myself with this kind of retarded shortco$$anonymous$$g. If you want my opinion, drag and drop is evil, but Unity is built that almost anything is made using it at some point.

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

MCF dialogs won't open in unity 0 Answers

Adding To Array From Editor 3 Answers

How do I bring up a dialog to let the user choose an asset? 2 Answers

I have a custom editor for a class which work's fine, but how do i refrence it in another class and get it ti appear? 1 Answer

Editor Input Dialog 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