Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
1
Question by Shinobi_Lord · Nov 09, 2021 at 01:51 PM · referencenamespaceusing

Unable to Reference a Class

Hi,

I'm using the A* Pathfinding project (https://arongranberg.com/astar/docs/beginner.html), and have come across a seemingly simple problem.

I am trying to access the A* Seeker class from one of my scripts. I have the using Pathfinding; directive at the top of the class but it is still not being able to be referenced/accessed.

  • have solved this problem before by moving the scripts into the same folder, but am wondering if there is another way to accomplish this.*

Thank you for any time and help.

EDIT :

To clarify, I downloaded the A* project and they have set themselves up in their own folder OUTSIDE of my scripts folder. In my scripts folder, I have created a script that tries to access/reference a script inside the A* folder. using Pathfinding; (the appropriate directive to the relevant namespace as evidenced by the other scripts/examples in the A* project) does not allow me to access/reference the script Seeker. I have solved this problem before by placing the custom script in the same folder as the Seeker script but am wondering how else to solve this, or at least why this is not resolving. Thank you.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Nov 09, 2021 at 03:42 PM

I haven't used the path finding project myself before. However I just downloaded the package, imported it into my test project and I have no issues accessing the classes. Note that the pathfinding project needs to be in its own seperate folder, since it has an assembly definition file which will instruct the Unity editor to compile the whole folder into a seperate assembly.


You said

it is still not being able to be referenced/accessed.

what exact error do you get in Unity?

Comment
Add comment · Show 4 · 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 Shinobi_Lord · Nov 09, 2021 at 10:48 PM 0
Share

Hi, thanks for your reply.

The error is : Assets\Scripts\StateMachine\005_21Sept24\TEST_Enemy_Basic_005.cs(12,10): error CS0246: The type or namespace name 'Seeker' could not be found (are you missing a using directive or an assembly reference?).

Again, if I create a custom script outside of the A* Project folder, it cannot reference/access the Seeker class, but if placed inside the A* Project folder, it is able to be accessed.

In my completely new custom script, I have only placed using Pathfinding; at the top. Am I missing something? Or maybe not "installing" the A* Project appropriately? (Simply importing the A* Project.)

Thanks for your time and help.

EDIT :

I just made a brand new project, imported the A* Project and attempted to do the same thing. I was able to access/reference the Seeker class from my custom script placed in a separate folder from the A* Project. The only thing I can think of that is done differently is the that my first (problematic) project is using the URP and whatever assemblies necessary and just being 2D.

avatar image Bunny83 Shinobi_Lord · Nov 09, 2021 at 11:16 PM 1
Share

Is it possible that the "StateMachine"folder also has an assembly definition file? You may have placed your script into a folder where you shouldn't. If that folder does have it's own assembly definition file you have two options:

  • Move the file out of that folder so it becomes part of the normal compilation group.

  • The second solution is to make the pathfinding assembly a dependency of that assembly where your script belongs to.

avatar image Shinobi_Lord Bunny83 · Nov 09, 2021 at 11:32 PM 0
Share

Hi again, thanks for your continued support.

There is no assembly definition file in the StateMachine folder, but there is an .asmdef file in the same folder that houses the StateMachine folder (the Scripts folder contains both the StateMachine folder and the .asmdef file in question; 1) Assets/Scripts/StateMachine, 2) Assets/Scripts/Scripts.asmdef).

Sorry, I'm a little unsure of which file you mean to move in your first solution. And the second solution I'm ignorant as how I would do that. I will try to pursue both solutions as soon as I am able, but any direction would be greatly appreciated.

Thank you again for your help and time!

Show more comments

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

132 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I use c# and have a problem about namespace System.Drawing! 3 Answers

How to implement custom using directives? 1 Answer

The type or namespace name could not be found. Are you missing a using directive or an assembly reference? 4 Answers

using System.Security.Cryptography.Xml in Unity 0 Answers

using UnityEditor outside of Editor folder when compiling build? 4 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