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 /
This question was closed Aug 17, 2017 at 01:59 PM by Igor_Vasiak for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by Igor_Vasiak · Aug 15, 2017 at 11:55 PM · scripting problemobjectinspectormethodvoid

How to select Object's voids through Inspector tab?

Issue:

I'm having some trouble. I want to be able to select any public void on the Objects I set up in the Inspector, but it's a really tricky thing to figure out, because Unity don't give any tips on how to do it. I imagine something like the Button.OnClick(). I set an Object, and then select a method.

I don't have any piece of code to show.


Conclusion:

As I'm not being able to figure it out, and don't know how to search it on Google, I'm asking here.

So, thanks in advance.

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

  • Sort: 
avatar image
3
Best Answer

Answer by M-G-Production · Aug 16, 2017 at 05:08 PM

There are lots of ways to do it!

If you want to do it like Button component, Look for UnityEvents. Example:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Events;
 
 public class CertainClass: MonoBehaviour
 {
     public UnityEvent theEvent;
     
     public void CertainVoid()
     {
         theEvent.Invoke();
     }
 }


You could also create an Enum with all the voids stored in it like this:

     public enum AllVoids
     {
         None,
         Void1,
         Void2,
         Void3
     }
     
     public AllVoids selectedVoid = AllVoids.None;
 
     public void CertainVoid()
     {
         switch(selectedVoid)
         {
         case AllVoids.Void1:
             Void1();
             break;
 
         case AllVoids.Void2:
             Void2();
             break;
 
         case AllVoids.Void3:
             Void3();
             break;
 
         default:
             debug.Log("Please Define a Void");
             break;
         }
     }
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 Igor_Vasiak · Aug 17, 2017 at 03:41 AM 1
Share

Thank you so much! It works!

avatar image
0

Answer by Destolos · Aug 16, 2017 at 06:16 AM

I think you need a custom inspector. Perhaps this Tutorial will help you: https://unity3d.com/de/learn/tutorials/topics/interface-essentials/adding-buttons-custom-inspector

Comment
Add comment · Show 2 · 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 Igor_Vasiak · Aug 16, 2017 at 02:04 PM 0
Share

Thanks for the answer, but I don't need a custom inspector for CALLING my methods. I need to drag an object to inspector, to another script, and select the script and the method that I want to use.

I need to do it this way to keep my scripts simple and clean.

Again, thanks for the answer.

avatar image Destolos Igor_Vasiak · Aug 16, 2017 at 02:24 PM 0
Share

Sorry, my fault. Is this what you are looking for: http://answers.unity3d.com/questions/1117974/make-method-variable-show-up-in-inspector.html ?

Follow this Question

Answers Answers and Comments

117 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

Related Questions

How to keep a moving object at the height of the terrain? (script) 2 Answers

How to move game object towards mouse on x and z only? 1 Answer

Display the same string in multiple text boxes 1 Answer

How to change azure spatial anchor objects? 1 Answer

Best way to defining scripts within a list inside the editor? 1 Answer


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