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 /
  • Help Room /
avatar image
0
Question by WaterMinecraft · Aug 21, 2015 at 04:56 PM · editorcustom editor

Calling script when completed field in *EDITOR*

I realize this may be super simple, but I'm actually working inside of a Custom List, so I have a Keycode, a Button and two string fields inside of my List, what I want to do is when I finish typing in my last string field, I want to run a script. Any ideas? Thank you! (:

Here is how my code is setup currently - What I need help with is how to get my current focus in the -Editor- then get the string value from this.

 using UnityEngine;
 using System.Collections;
 using UnityEditor;
 using System.Collections.Generic;
 using UnityEngine.UI;
 
 [CustomEditor(typeof(InputManager))]
 public class InputManagerEditor : Editor {
 
     public override void OnInspectorGUI()
     {
 
         serializedObject.Update ();
         InputManager myTarget = (InputManager)target;
 
         EditorGUILayout.PropertyField(serializedObject.FindProperty("inputManagerList"), true);
 
         if(!GUI.GetNameOfFocusedControl().Equals("") && Event.current.keyCode == KeyCode.Return)
             TagEditor.AddToTagMenu(GUI.GetNameOfFocusedControl().ToString());
 
         serializedObject.ApplyModifiedProperties();
 
     }
 
 }

Comment
Add comment · Show 1
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 WaterMinecraft · Aug 29, 2015 at 07:22 PM 0
Share

I still have been unable to figure out how to do this, anyone have any ideas?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jessespike · Aug 21, 2015 at 05:08 PM

You can probably do a check to see what control is focused and if the field is no longer empty. Simple example, but for a starting point, try something like this:

  /*pseudo*/
  if (lastFocusedControl == myInputField && myInputField != string.empty)  {
       //Call your script
  }

http://docs.unity3d.com/ScriptReference/GUI-changed.html

http://docs.unity3d.com/ScriptReference/GUI.FocusControl.html

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 WaterMinecraft · Aug 23, 2015 at 12:34 AM 0
Share

Thank you for replying so quickly, I'm sorry for being late!

So, I'm unsure how to name my TextField... Here is my code. What would be ideal is to actually connect the script call (The if statement) to when my tag field inside of my List is filled out.

CODE:

 using UnityEngine;
 using System.Collections;
 using UnityEditor;
 using System.Collections.Generic;
 
 [CustomEditor(typeof(Input$$anonymous$$anager))]
 public class Input$$anonymous$$anagerEditor : Editor {
 
     public override void OnInspectorGUI()
     {
 
         serializedObject.Update ();
         EditorGUILayout.PropertyField(serializedObject.FindProperty("input$$anonymous$$anagerList"), true);
 
         EditorGUILayout.TextField("Add tag");
 
         //FIX THIS TODO
         if(GUI.GetNameOfFocusedControl().Equals(""))
         {
 
             if(Event.current.type == EventType.$$anonymous$$eyUp && Event.current.keyCode == $$anonymous$$eyCode.Return)
             {
                 Debug.Log("Reached");
                 TagEditor.AddToTag$$anonymous$$enu(GUI.GetNameOfFocusedControl().ToString());
 
             }
 
         }  
 
         serializedObject.Apply$$anonymous$$odifiedProperties();
 
     }
 
 }

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

25 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 avatar image avatar image avatar image

Related Questions

Custom Editor List with child classes 1 Answer

Adding space() to BeginHorizontal() causes extra vertical spacing after certain amount. 1 Answer

Dynamically sized list of toggles in custom inspector? 0 Answers

How do I draw information, extending the "Project/Assets/" Window? 0 Answers

ReorderableList (or similar) for UIElements 0 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