Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

how to use OnSubmit ?

Discussion in 'Scripting' started by ozgurdugmeci, Oct 13, 2015.

  1. ozgurdugmeci

    ozgurdugmeci

    Joined:
    Mar 1, 2015
    Posts:
    85
    I want to use OnSubmit function for the inputfields.

    I typed the script below.
    There is no error on console but i couldnt print it.

    how can i use it in a proper way?

    Code (JavaScript):
    1. import UnityEngine.EventSystems;
    2.  
    3. class tekst extends MonoBehaviour implements ISubmitHandler
    4.  
    5. {
    6.  
    7.     function OnSubmit(eventData : BaseEventData)
    8.     {
    9.      
    10.         Debug.Log (" hahaha ");
    11.      
    12.     }
    13. }
    14.  
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
    OnSubmit (like all the New UI functionality) isn't called automatically (it's not like Update, OnCollisionEnter, etc). You'll have to add a component called EventTrigger to your GUI object. Then click "Add New Event Type" and choose Submit. That will create an event "box", and in that box you'll link up your function.
     
  3. ozgurdugmeci

    ozgurdugmeci

    Joined:
    Mar 1, 2015
    Posts:
    85
    i got it.
    thank you starmanta.