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 kevinrocks_786 · Dec 27, 2015 at 07:05 AM · c#unity5inspectormethodmethods

Make method variable show up in Inspector

Hey, so I'm trying to achieve what you see below...

alt text

See the "OnClick"?

I kind of want to make a method/void variable show up in inspector and then use it. Thanks

42377-capture2.png (22.2 kB)
Comment
Add comment · Show 6
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 Wilson28300 · Dec 27, 2015 at 07:17 AM 0
Share

Which variable do you want to show up in the Inspector? Is the variable in a script?

avatar image kevinrocks_786 Wilson28300 · Dec 27, 2015 at 07:22 AM 0
Share

Not a variable, a method. I want to make a method field. Where i can drag in a GameObject, see it's attached components/scripts and call methods from them. Just like you do with UI buttons.

avatar image JedBeryll · Dec 27, 2015 at 08:22 AM 0
Share

I think what you see on the picture is an enum and the method is chosen by a switch (not sure though). For the method to show up I imagine you would need custom editor setup. You can use Action to store methods.

avatar image kevinrocks_786 JedBeryll · Dec 27, 2015 at 08:25 AM 0
Share

Right but I cant do

 public Action method;
 //or
 public Action[] method;
avatar image JedBeryll kevinrocks_786 · Dec 27, 2015 at 08:28 AM 0
Share

I'm not sure what you mean. I found a discussion about this: http://forum.unity3d.com/threads/reflection-method-selection-with-an-editor-script.142405/

Show more comments

1 Reply

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

Answer by kevinrocks_786 · Dec 27, 2015 at 08:36 AM

So I answer my own question... It turns out you have to include the namespace:

 using UnityEngine.Events;

And then to have it appear in the editor, you do

 public UnityEvent methods;


Then to activate them, you do

 methods.Invoke();

Even though I found my own answer, thanks @JedBeryll for your time.

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

52 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

Related Questions

Distribute terrain in zones 3 Answers

Methods list in inspector 0 Answers

Create a seed or string to run multiple methods. C# 3 Answers

Calling a variable based on a variables name? 1 Answer

How to check if a public method is referenced in inspector 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