Obi Official Forum
Help I want to modify ObiTearableCloth.cs and access scripts from other folders. - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: Help I want to modify ObiTearableCloth.cs and access scripts from other folders. (/thread-2695.html)



I want to modify ObiTearableCloth.cs and access scripts from other folders. - k2xh0115 - 12-01-2021

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


RE: I want to modify ObiTearableCloth.cs and access scripts from other folders. - josemendez - 12-01-2021

(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/ScriptCompilationAssemblyDefinitionFiles.html
- Namespaces: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/namespaces/
- 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,