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 /
avatar image
0
Question by mellooow9 · Jan 24, 2020 at 08:31 AM · uiinputfield

How do I type my own paramater in a function on an input field?

alt text

This function takes a string as a parameter, but since it's on an input box, it's taking the text of the input field as the parameter. How do I make it so I can type in my own string instead?

(this is for unity 2017)

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Jan 24, 2020 at 05:01 PM

Well, It's not clear what kind of UnityEvent this is. If it is a UnityEvent that actually takes a string parameter when invoked, that parameter is passed from the caller. If the field is just an ordinary UnityEvent without parameters, you have to select the right method from the drop down list. It might be listed several times, once without parameter and once with.

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 mellooow9 · Jan 26, 2020 at 08:21 PM 0
Share

the "unity event" is the "vrc_trigger.executecustomtrigger"? then yes it takes a string as a parameter.

the "caller" is the inputfield? well i want to know how to write in my own string as a parameter, ins$$anonymous$$d of using the one from the inputfield. if i put this function on a button, then it does let me type in my own.

avatar image Bunny83 mellooow9 · Jan 27, 2020 at 10:26 AM 1
Share

No, you did not understand what I meant ^^. I was talking about the script which has this UnityEvent field where you want to assign your VRC_Trigger.ExecuteCustomTrigger method to.

We have no context where you actually assigned your method to. What is the type of field of this UnityEvent? Do you have written the script where the inspector in the screenshot belongs to? If so, that code is what I was asking for.


For example: If you write this in a script:

 public UnityEvent someEvent;

Then when you inspect your script you will see exactly this inspector snippet that you have shown us. However there are different UnityEvent types available. This one has no parameter at all. Within this script we can just use: someEvent.Invoke(); to actually call the method whatever you assigned in the inspector.


Now there are also other UnityEvents and this one takes one parameter. If order to use them you have to create a derived class with your desired parameter type as shown in the example in the documentation. When we use that new type $$anonymous$$yIntEvent in a script we again get the same inspector we see in your screenshot:

 pubic $$anonymous$$yIntEvent someOtherEvent;

However this time this event requires an int parameter. Now the user (who assigns a method in the inspector) can only select methods which actually take an int parameter. This int parameter has to be passed when you invoke / call that event

 someOtherEvent.Invoke(42);


When you assign a method with a parameter to a UnityEvents without parameters, the inspector will allow you to specify one parameter if the parameter is a primitive type (string, int, float, bool, ....).


If the event is just a parameterless event you can assign methods without parameters (of course) and also methods with one parameter.

If the event type already expects a string parameter you can select different options. The method listing is divided into "dynamic string" methods at the top and "static parameters" on the bottom. A method with a string parameter will show up in both sections. However the top one will receive the string value that the caller pass to the event. The bottom one will ignore the value passed by the caller and allows you to specify the string value statically in the inspector.

avatar image mellooow9 · Jan 27, 2020 at 09:47 PM 0
Share

okay thanks. i didnt write the script btw, but i see the same method is listed twice now, and one of them lets me type the string. thnx ^^

avatar image
0

Answer by logicandchaos · Jan 27, 2020 at 05:37 PM

If it uses an InputField then it should be defined somewhere in your scene hierarchy, you should be able to set it there.

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

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

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

Related Questions

InputField instance isFocused always return false. 0 Answers

How do i check the inputted text in a Multi line Input field? 1 Answer

InputField's OnEndEditting: Triggered when input (click, touch, etc) on other area rather than InputField. 0 Answers

Android Keyboard Stuck / Won't Hide? 1 Answer

UI InputField Undo Redo 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