• 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 aadikhan859 · Nov 29, 2022 at 01:53 PM · expose

Trying to expose Custom Event from Scriptable Object

alt text

Hi! I am trying to expose a Custom event from a scriptable object so I can bind the creature effects to the creature assets in the inspector, and I am not being able to get the methods listed in the script I am attac$$anonymous$$ng, here are the points - 1 Scriptable object from w$$anonymous$$ch I created the asset, - 1 custom event class is done, - The custom event is exposed, I have the effects class w$$anonymous$$ch contains the effects for each creature now I want to bind those methods to the event in the inspector of the specific creature.

but I can't seem to get t$$anonymous$$s 1 part to work Any suggestion would be helpful.

MY Codes t$$anonymous$$s is the event class very basic

 [Serializable]
 public class CustomCardEvents : UnityEvent<bool>
 {
 
 }

editor code

 public SerializedProperty ActionEvent;
 
     void OnEnable () {
         //ActionEvents
         ActionEvent = serializedObject.FindProperty("ActionEvents");
     }
  public override void OnInspectorGUI() {
         serializedObject.Update ();
 EditorGUILayout.PropertyField(ActionEvent);
         serializedObject.ApplyModifiedProperties ();
     }

my custom class code(the script i am attac$$anonymous$$ng)

 public class myCustomEvents : MonoBehaviour
 {
     [SerializeField]
     public CustomCardEvents onChangeEvent;
     public bool effect(int a)
     {
         return true;
     }
 }

scriptable object code

 [CreateAssetMenu(fileName="New Card", menuName="Card")]
 public class Card : ScriptableObject
 {
     public CustomCardEvents myevents;
     
     [Header("General Info")]
     public Rarity rarity;
     public string id;
     public Sprite art;
     public Material material;
     public new string name;
     public Families family;
     public CardType type;
     public string ability;
     
     [Header("Creature Stats")]
     public Planets planet;
     public Resource resource;
 
     [Range(0, 1000)]
     public int power;
     [Range(-1, 10)]
     public int resistance;
     [Range(0, 20)]
     public int speed;
     [Range(0, 20)]
     public int level;
     [Range(0, 10)]
     public int aggression;
 
     [Header("Special Addition Stats")]
     public bool target;
     [Range(0, 3)]
     public int specialTagretCount;
 
     [Header("Special Unexpected Stats")]
     [Range(0, 3)]
     public int specialSpeed;
 
     [Header("Custom Events")]
     public CustomCardEvents ActionEvents;
     public event Action<bool> CustomEvent;
 }
 

screenshot-275.png (59.9 kB)
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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

195 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

Related Questions

How to create Generics Property Type Property Drawer 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