Skip to content
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

Unity editor become very slow if reorder List has large struct and large array elements. #12

Open
LoS-Light opened this issue Jan 8, 2019 · 2 comments

Comments

@LoS-Light
Copy link

Unity editor is very slow if reorder List has large struct and large array elements.

@LoS-Light LoS-Light changed the title Unity editor is very slow if reorder List has large struct and large array elements. Unity editor become very slow if reorder List has large struct and large array elements. Jan 8, 2019
@mages-gamedev
Copy link

mages-gamedev commented Feb 20, 2019

I also noticed the same thing when these structs and array elements contain ScriptableObjects.

Here are several tests I've done:

  1. ScriptableObject containing classes which contain ScriptableObject fields will lag if both #LIST_ALL_ARRAYS and #EDIT_ALL_SCRIPTABLES are uncommented
  2. ScriptableObject containing classes which contain ScriptableObject fields will not lag if only #LIST_ALL_ARRAYS is uncommented

I've also noticed that if a ScriptableObject contains classes which contain ScriptableObjects, the classes' ScriptableObjects are not editable.

Solution
I made a new PropertyAttribute called NonEditScriptableProperty and added the new header into any child ScriptableObject fields of a ScriptableObject

public class NonEditScriptableAttribute : PropertyAttribute { }

And edited this in ReorderableArrayInspector.cs starting from line 367:

#if EDIT_ALL_SCRIPTABLES
    bool makeEditable = !iterProp.HasAttribute<NonEditScriptableAttribute>();
#else
    bool makeEditable = iterProp.HasAttribute<EditScriptableAttribute>();
#endif

The logic in play here is to set makeEditable to false if a field has the NonEditScriptable attribute. Add this attribute to any inner ScriptableObjects and you should notice that the lag is gone. I have not tested on large Lists of ScriptableObjects.

Example:

[SubjectNerd.Utilities.NonEditScriptable]
[Tooltip("A un-editable ScriptableObject")]
public MyScriptableObject myScriptableObject;

Hope this helps! @LoS-Light @ChemiKhazi

@LoS-Light
Copy link
Author

LoS-Light commented Feb 21, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants