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
0
Question by YetAnotherUnityQuack · Oct 14, 2010 at 10:07 AM · editor-scriptingeditorwindow

EditorWindow not working when defined in .net/mono Assembly.

Using Visual Studio and Unity 3.0.0f5, I'm trying to define a EditorWindow Class In an external .net assembly.

using System; using UnityEditor; using UnityEngine;

public class MyCustomWindow : EditorWindow { private static MyCustomWindow _windowInstance = null; [MenuItem("Window/Test")] public static void Init() {

     MyCustomWindow e = MyCustomWindow.CreateInstance<MyCustomWindow>();
     if (_windowInstance != e)
     {
         e.SomeOperation();
     }
     _windowInstance = e;

 }
 public void SomeOperation()
 {
     Debug.Log("Ran some operation");
 }

}

//output error on menu selection //Instance of MyCustomWindow couldn't be created because there is no script with that name. //UnityEngine.ScriptableObject:CreateInstance() //MyCustomWindow:Init()

The menu selection Item appears, but when used it gives the above output. I have an idea that I will have to, if possible, manually register MyCustomWindow to some list of window classes.

Has anyone successfully put an EditorWindow class in a .net assembly dll?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Alex-Chouls · Oct 21, 2010 at 09:30 PM

I use a small wrapper script that calls the class in the dll.

The wrapper class is a regular script that extends EditorWindow and keeps a reference to the dll class. It then forwards any EditorWindow events you're interested in handling to the class in the dll. Note, the class in the dll does NOT extend EditorWindow, it just implements the functionality (OnGUI etc.)

Typically the wrapper class initializes the dll class with itself, so the dll class can call EditorWindow methods, e.g., Close()...

Tried to copy/paste some code, but the formatting controls in this edit box suck and I ran out of patience!

I also tried the "Adapter" method described in this thread, but could't get it to work with EditorWindow...

If you find a better way to do this, please share!

Comment
Add comment · Show 1 · 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 YetAnotherUnityQuack · Oct 22, 2010 at 12:03 AM 0
Share

Thanks for your answer! I'm about at where you are; settled with the wrapper solution

avatar image
0

Answer by Mudloop · Mar 24, 2012 at 05:11 PM

I'm not sure if this is new in Unity 3.5, but placing the dll in an Editor folder seems to work for me. So I work with two separate dlls - one for the game classes, and one for the editor classes.

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

1 Person is following this question.

avatar image

Related Questions

EditorWindow reference to other scripts functions 0 Answers

Weird bug when dragging object onto EditorGUILayout.ObjectField 0 Answers

Creating Editor 2D Animation Preview 2 Answers

mouseposition and clicks in editor sceneview 0 Answers

EditorWindow, Utility Popup, not using custom PropertyDrawers 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