-
-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ButtonMethod] not work in list item #231
Comments
It happened to me recently. In a button method I do something like
|
I think it might be related to prefabs. I found that, if the game object is not from a prefab, this button method in editor works fine, the value is not lost after playing. I guess |
In this page: https://docs.unity3d.com/ScriptReference/EditorUtility.SetDirty.html
A prefab instance works with this piece:
|
@Deadcows Also, would you like if add these two lines to
I am not pretty sure this would fit every cases of this issue😂, at least I tried myself it works with scene objects/ prefab instance/ modification of other objects in the scene. |
I don't like the idea that it always makes the scene dirty. I tried that and it made some undesired behaviors in my previous project 🤔 (several game designers pushed a bunch of changed scenes in vcs causing a lot more conflicts that it should 😅) Maybe it's better to dirty it if the "result" is not null and cast to "true"? So, if ButtonMethod returns bool and explicitly indicates that the scene should be marked dirty as a result of its invocation 🤔 So, usage will be like this:
Would be optional, and easily explained in docs. Nicely combined with |
However the return type of this method is restricted to bool 🤔. If a method written before returns bool, after this update may cause unexpected results.
If
Nice discussion! Also, I like your games! 😊 |
Yep, backward compatibility is a thing I always forget about 😅 I don't like the optional parameter thing, because the decision to make dirty often comes in the body of the method. Why not create a custom type as a flag for a ButtonMethod, then? This will allow to keep the default behavior with logging for all other types 👍🏻
btw, is it safe to call RecordPrefabInstancePropertyModifications on any objects or we should check if target object is part of a prefab first? And it also probably should only be called during prefab-editing-mode, to not force the changes made on prefab instance 🤔
Thank you, mate! Working hard on the third project, so not have that many time to spend on MyBox now. But I'll make a big update when sort all the cool things I made during the work on The Bookwalker 🙂 |
@Deadcows
From my own experience, most of time a button method does something about changing serialized values (from Monobehavior, ScriptableObject or a serializable class). I would say by default
I tried in my project,
What would you think?❤️ |
[ButtonMethod] do works in an independent item,
but it fail when come to the list item in a list/dictionary
The text was updated successfully, but these errors were encountered: