Search Unity

Custom editor in multiple projects editor layout

Discussion in 'Scripting' started by Joe ByDesign, Jul 28, 2011.

  1. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Have the same custom editor window class imported into multiple projects also saved in a custom editor layout.

    Every time we switch between projects, the place where the custom editor window was saved in the layout, instead shows an error:
    Code (csharp):
    1. EditorWindow could not be loaded because the script could not be found in the project
    despite the class still existing in the project.

    Have to manually re-create re-place the custom editor window EVERY TIME WE SWITCH PROJECTS. It is tedious.

    Is there any solution for this? Incorporate some ID into the class or something?

    At least something until UT allows "inter-project" Editor classes... :)
     
  2. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    I too would be interested in an answer to this.
     
  3. ModStoryGames

    ModStoryGames

    Joined:
    Apr 27, 2012
    Posts:
    179
    Find the folder where the Asset Store saves your packages, and you should be able to drop your package into it. When you start a new project, the package should appear in the list of packages.

    ----

    Tested. Export your editor window as a package. Find the location for your Asset Store downloaded packages, and create a folder in it. Call it MyPackages or whatever. Inside that, create a folder and name it after the editor window or whatever you want. Inside that, place the package.

    The next time you create a new project you will find your asset in the list.

    EDIT:

    Asset Store Folder Locations:

    Older Windows: C:/Documents and Settings/<username>/Application Data/Unity/Asset Store
    Windows 7: C:/Users/<username>/AppData/Roaming/Unity/Asset Store
    Mac: ~/Library/Unity/Asset\ Store

    I can only confirm Windows 7 location.

    EDIT 2: I know this isn't perfect, because it won't affect previously created projects, but if you package your window, you can drag it into any project and double click it to import the folders/classes/etc. Then delete the package file (that is in the project).
     
    Last edited: Jun 11, 2012
  4. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    Alternatively, turn on .meta files for each project, then copy the .meta file for the editor script from one project to the others. That way all the projects should have it with the same GUID.
     
  5. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    @EddyEpic
    You may have misunderstood the post. Post isn't about how to have access to the same package across multiple projects.

    It is rather about having the same editor extension / view installed in multiple projects, and not having to recreate replace the extension in the Editor Window layout every time we switch projects.

    @Superpig
    Will try this and report back! :)
     
  6. Nition

    Nition

    Joined:
    Jul 4, 2012
    Posts:
    781
    Joe ByDesign never reported back, but I'm going to: This still seems to be broken for me in Unity 4.2, and superpig's suggestion didn't seem to help. Is it happening for anyone else?

    Just as described above, if I close my project and come back, everything is fine, but if I load a different project and then come back, my custom editor windows can't be found and they have to be closed re-opened.
     
  7. RemoteBrainSoft

    RemoteBrainSoft

    Joined:
    Jun 6, 2014
    Posts:
    59
    Had the same problem and actually managed to figure out the solution!
    In my case, the MenuItem was defined in the same class used by GetWindow.
    By separating the MenuItem to its own class the problem got solved.
    I placed both files inside the editor folder, but I never tested if one of them can be moved to a different folder.
     
  8. MinsukCha

    MinsukCha

    Joined:
    Jun 9, 2014
    Posts:
    13
    VatelsRevenge likes this.
  9. VatelsRevenge

    VatelsRevenge

    Joined:
    Feb 10, 2012
    Posts:
    14
    MinsukCha has it.

    I had the same problem and it was driving me nuts. I had created a custom window and it was supposed to load whenever I opened the project, but instead it would "Fail to Load".

    My problem was that my editor window's class was called "ToolsEditorWindow" and was held within a script named "TheTools.cs". It made sense at the time - the script held 2 classes in it: a "TheTools" class which held all the lengthy functions that the buttons in my "ToolsEditorWindow" class activated.

    To fix it, I renamed the Editor Window class to "TheTools" to match the "TheTools.cs" file name and renamed the class that held all the extra functions "ToolFunctions". Now everything loads as it should.