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

Calling new on an Editor should suggest to use Editor.CreateEditor() #1984

Open
citizenmatt opened this issue Dec 29, 2020 · 0 comments
Open

Comments

@citizenmatt
Copy link
Member

Given a class that derives from Editor, if calling new MyEditor(), Rider will suggest to rewrite this as ScriptableObject.CreateInstance<MyEditor>(). However, since it's an Editor class, it should actually rewrite as Editor.CreateEditor($TARGET$).

  • It might be better to suggest Editor.CreateEditor($TARGET$, typeof(MyEditor)), in case there are multiple editors for the given target type, and new was being called on a specific type.
  • Look at the editor type and find the [CustomEditor(typeof(_target_))] to find the type of the target object, and filter suggestions for $TARGET$ based on this type.
  • Possibly suggest Editor.CreateEditor or Editor.CreateEditorWithContext to allow passing in a context object. I don't know how to suggest what the context object should be.
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

1 participant