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
0
Question by Aria-Lliane · Aug 06, 2013 at 11:42 PM · guiunityeditoreditorwindowwindow

Converting from EditorWindow to runnable window

Hi, i had built an EditorWindow but then i noticed that it will not be whit the actual game after build, so i started making the same window but using GUI elements, for it to be inside the game.

So far ive almost converted most of stuff but there are still some elements that i havent been able to convert:

         EditorGUILayout.Popup
         EditorGUILayout.IntField
         EditorGUILayout.HelpBox

What is their GUIlayout equivalent, or if it doesn't exist, how can i replicate them?

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
2

Answer by numberkruncher · Aug 07, 2013 at 12:07 AM

As you suspected these are not available within the runtime API.

`EditorGUILayout.Popup`

You could use a button and then simulate the popup area using either `GUI.BeginScrollView` or `GUILayout.BeginArea`.

`EditorGUILayout.IntField`

You could simulate this with something like the following (not tested, but you should see the basic idea):

 using UnityEngine;
 using System;
 using System.Text.RegularExpressions;

 public static class YourGUI {

     public static int IntField(int value) {
         // Format integer into string for text input.
         string textInput = GUILayout.TextField(value.ToString());

         // Extract valid characters from input.
         Match m = Regex.Match(textInput, "[+-]?[0-9]+");
         textInput = m.Success ? m.Value : "0";

         // Convert from string to integer.
         return Convert.ToInt32(textInput);
     }

 }

 // Usage:
 yourInt = YourGUI.IntField(yourInt);

`EditorGUILayout.HelpBox`

This is essentially a glorified label. You could achieve this with a custom style (perhaps based upon GUI.skin.box) with three custom icon textures. Here is a pseudo-example (again not tested):

 public enum YourMessageType {
     None,
     Info,
     Warning,
     Error
 }

 private static GUIContent _tempContent = new GUIContent();

 public static void HelpBox(string message, YourMessageType type = YourMessageType.Info) {
     _tempContent.text = message;
     switch (type) {
         default:
         case YourMessageType.None:
             _tempContent.image = null;
             break;
         case YourMessageType.Info:
             _tempContent.image = yourInfoIcon;
             break;
         case YourMessageType.Warning:
             _tempContent.image = yourWarningIcon;
             break;
         case YourMessageType.Error:
             _tempContent.image = yourErrorIcon;
             break;
     }
     GUILayout.Label(_tempContent, yourHelpBoxStyle);
 }

I hope that this will be of help to you :)

Comment
Add comment · Show 3 · 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 Aria-Lliane · Aug 08, 2013 at 09:09 PM 0
Share

Thank you alot for your answer, helped alot.

Still, Unity.GUIlayout.Sucks.RageQuitForToday(). (I'm sure i'm doing something wrong, but damn i'm full of this for today)

avatar image Aria-Lliane · Aug 10, 2013 at 04:50 PM 0
Share

Finally everything is working fine, except my pseudo-popup box, basically I just make a new small window on the place of the mouse with a button for each option, i just have 3 issues i cant figure out on my own. 1)this new window should return a value. 2)clicking anywhere outside this $$anonymous$$i window should make it close. 3)resizing the box rect so it can adjust to the text size of the options

Have any ideas?

avatar image Aria-Lliane · Aug 11, 2013 at 06:11 AM 0
Share

Not perfect but: http://webx.ubi.pt/~a23002/SpellCustomizer/build.html

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

15 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

Related Questions

Unity editor creates a lot of default objects. Why? 0 Answers

Close()ing an EditorWindow 2 Answers

Elements in draggable window do not remain fixed [SOLVED] 2 Answers

how will i get every time values in table window? 0 Answers

Get Mouse Events with EditorWindow 3 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