Scripts from local package cannot find scripts in Assets

Hello,

I have a setup where some scripts are stored under Assets/Grid Framework/Plugins/ and I need reference these scripts from with a local package stored under Packages/com.hiphish.grid-framework.samples/. Here is what one of the package scripts looks like:

using UnityEngine;
using GridFramework.Renderers.Rectangular;

namespace GridFrameworkSamples.Endless2D {
   // ...
}

The first using statement works, but the other one raises a compile-time error that the GridFramework.Renderers namespace cannot be found. That namespace definitely does exist, I can create instances of its classes in the editor without issue. My understanding is that the package needs to be told to reference the assemblies it needs to use, but I have no idea how to do that for a namespace that is not inside another package but part of the project.

Here is what I am trying to achieve: Grid Framework is a plugin I’m selling on the Asset Store and I want to make usage examples available as a Git package. Originally I wanted to make the entire Grid Framework a package, but it is impossible to upload anything outside the Assets folder to the Asset Store. So the next best thing to do would be to at least move the examples into a package; people would first install Grid Framework, and if they want examples they can install the extra package. Why not include the examples directly? Because if I do that then the example scripts and textures end up spamming the user’s project.

I have also Playmaker and Vectrosity support and I had no issue referencing their packages. Somehow it works for them.

Pretty sure this is why you see this issue:

There are various choices you can make to remedy.

1 Like

Thank you, that link led me down the right path. For anyone reading this in the future: I have organized the main files as follows:

Assets/Grid Framework/
β”œβ”€β”€ Editor
β”‚   └── ...
└── Runtime
    β”œβ”€β”€ ...
    └── com.hiphish.grid-framework.Runtime.asmdef

I have omitted the metadata files. The important point is to have the assembly definition file. I put it inside the Runtime directory (which contains all the business logic) because I don’t want to bloat it with editor scripts. I might add a separate assembly for the editor scripts if it becomes necessary. The name is unimportant, the location is what matters. The default settings in the assembly definition are sufficient (make sure it is auto-referenced). I also set the root namespace to GridFramework, no idea is that is actually necessary.

Now comes the second step: inside the package (which contains the samples in my case) there should already be an assembly definition. This assembly definition must reference the previously created assembly definition. This will allow the samples to find all the class definitions.

1 Like