Reputation: 91
I have 3 folders in my project, named scripts, photon and standard assets. Now I need to make a reference from the standard assets folder to a script in the 'scripts' folder, which is possible only if I copy the folder into the standard assets(because it has a different namespace).But I get an error with the photon.So is there a way to make a reference without copying the folder?
using UnityEngine;
namespace UnityStandardAssets.CrossPlatformInput
{
public class ButtonHandler : MonoBehaviour
{
public wepScript ws; //error cannot find wepScript
}
}
using UnityEngine;
using System.Collections;
public class wepScript : MonoBehaviour {
}
Upvotes: 0
Views: 4563
Reputation: 156
Actually, namespace
is not something related to the Unity. You can use whatever namespace
or code
in your classeses. You just need to include the namespace via using.
using UnityEngine;
using System.Collections;
For example:
I have a script under Standard Assets
folder called Weapon
.
using UnityEngine;
namespace FooNamespace
{
public class Weapon : MonoBehaviour {
public void LogMeUp()
{
Debug.Log("I have been called");
}
}
}
And then, I have GonnaCallWeapon
script somewhere else.
using UnityEngine;
using FooNamespace;
public class GonnaCallWeapon : MonoBehaviour {
public Weapon weapon;
void Start () {
weapon.LogMeUp();
Debug.Log("I called LogMeUp");
}
}
Weapon
, and GonnaCallWeapon
scripts to an object in the hierarchy, and set up the weapon
variable.Upvotes: 1