0

I am trying to reference "where" all the class definitions I create, in the Project folder, are located, so I can gather the class types for use in an Editor script. Which means, they must exist "somewhere", or I would not be able to reference them from the Project folder using IntelliSense, and would also get errors that the type does not exist if I declared using the type.

If I can put these types into a collection, I can use them in my custom Editor window.

My research has yielded that Assemblies may be where the types are stored. Is this true? And if so, which Assembly contains the Project folder's class-definition types.

2 Answers 2

1

Unity creates its own assembly definitions for the entire project

(Two, actually, one runtime and one editor: Editor can reference runtime, but not vice versa; this dependency is set automatically and you don't have to do anything (but creating your own namespaces is a good idea!1))

Scripts created in the assets folder under these rules shows up in the solution under Assembly-CSharp (the project) /Assets/<where ever you created your script file>

For example:

Solution window

However, you can also create your own Assembly Definitions, which will include everything in the same folder and below automatically. For example I am using Stompy Robot's runtime debugger console, but I don't want to make Unity recompile that every time I make a change to my code, so I created an assembly def for it (three, actually, because of the two Editor magic folders).

SR debugger in UnitySR debugger VS

If you do so, you have to tell the assembly def that you want to reference another assembly, as I had to do with the two Editor assembly defs. However, you can't add a reference to the main Unity assembly.

For example, one of the two Editor assemblies for SR's Debugger.

SR Debugger Editor assembly

I hope that helps unravel the mysteries somewhat.

  1. It is possible that you're trying to figure out how to import your non-editor files inside your editor files. If you don't have a namespace they exist at the top "global" level and should automatically be visible. Unity does nothing special here, but it is recommended that you create your own namespaces for both runtime and editor.
0

<Unity project name>/Library/ScriptAssemblies/Assembly-CSharp.dll

This is the default assembly, the file name is variable if you create assembly definition in your project.

<Unity project name>/<Unity project name>.CSharp.csproj

This is the default project file, you can also add it into your own project then refer to it.

1
  • While this more directly answers the question, Draco18s thorough response provides solid details about this question as well. Jul 1, 2019 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.