Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  I want to modify ObiTearableCloth.cs and access scripts from other folders.
#1
It is possible to create a new c# script in the same folder on ObiTearableCloth.cs to access the class. But I can't access it from the other folder I made.
I want to modify ObiTearableCloth.cs and access c# script's class in my newly created folder.
What should I do?

Thank you for answering my question last time. you're the best! Gran sonrisa
Reply
#2
(12-01-2021, 07:51 AM)k2xh0115 Wrote: It is possible to create a new c# script in the same folder on ObiTearableCloth.cs to access the class. But I can't access it from the other folder I made.
I want to modify ObiTearableCloth.cs and access c# script's class in my newly created folder.
What should I do?

Thank you for answering my question last time. you're the best! Gran sonrisa

Hi there,

Short answer: add this to the top of your script:

Code:
using Obi;

Long answer: You don't need to place your script in the same folder as another to be able to use it. This is not how programming works (at least C#, C++, Java and a few others, though I'm unsure if there's any programming language in which physical file location acts as an access qualifier/namespace).

In Unity/C# there's 3 main things that modify/restrict access:
- Assemblies:  https://docs.unity3d.com/Manual/ScriptCo...Files.html
- Namespaces: https://docs.microsoft.com/en-us/dotnet/...amespaces/
- Access qualifiers: https://www.w3schools.com/cs/cs_access_modifiers.asp

In your case, the most probable cause for not being able to access ObiTearableCloth is that you're not qualifying it properly: you should either write it as "Obi.ObiTearableCloth" (note the Obi.- prefix, signaling that the class exists within the Obi namespace) or place "using Obi;" at the top of your file to make the entire Obi namespace available to your script.

cheers,
Reply