Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by LaireonGames · May 18, 2015 at 04:49 PM · editor-scriptingevents

Custom Inspector: Unity Events

Hey everyone, I am having trouble today with a custom inspector that handles UnityEvent's. Whats happening is that if I make a custom inspector for a UnityEvent then I can set all the data fine but if I select a new object then the data for the input of the method is lost.

So:

alt text

This is the result after selecting another object and returning. As you can see which method to run and which object to send the message to is retained but any input data is always lost. This even applies for simple methods such as gameobject.SetActive so it effects primitive data as well as objects.

Anyone any ideas if I am doing anything wrong or is this a bug?

(To recreate create a custom inspector and display an event using a property field)

Cheers! Jason

forum.png (15.1 kB)
Comment
Add comment · Show 3
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 Jean-Fabre · Jul 20, 2015 at 03:38 PM 0
Share

I am looking for this as well. in trying to use SerializedProperty, I always get null

avatar image LaireonGames · Jul 20, 2015 at 06:13 PM 0
Share

I'm glad its not just me then! Still no progress on this from me unfortunately :(

avatar image Jean-Fabre · Jul 21, 2015 at 05:51 AM 0
Share

@$$anonymous$$2 Games. I got it working in the end, added the link as an answer

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by mikrima · Dec 10, 2015 at 05:25 PM

I had the same issue - the parameter values would always disappear. Here is what worked for me in the end:

  1. Call "serializedObject.Update();" in the beginning of OnInspectorGUI

  2. Call "serializedObject.ApplyModifiedProperties();" at the end of OnInspectorGUI

  3. Either DON'T draw the default inspector, or draw it AFTER the call to ApplyModifiedProperties (otherwise your value will jump right back to what it was before)

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

Answer by Jean-Fabre · Jul 21, 2015 at 05:51 AM

Hi,

That worked for me: http://answers.unity3d.com/questions/802786/46-how-do-i-draw-unityevent-in-custom-inspector.html

Bye,

Jean

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

21 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

Related Questions

UnityEvent Serialization Problem 1 Answer

Unity Editor Scripts: GameObject Added / Removed Event? 1 Answer

Non-monobehavior editor script subscribing to delegate event and persisting on application reload 0 Answers

Event.current.Use() not consuming event in editor SceneView 1 Answer

Is there a way to implement mouse events in the game view in edit mode? 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