유니티 편집기에서 게임을 개발하려고합니다. 한 스크립트에서 다른 스크립트로 네임 스페이스를 사용할 수 없습니다. 아래 스크립트를 찾으십시오.C#에서 네임 스페이스를 사용할 수 없습니다.
using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
namespace UnityStandardAssets.CrossPlatformInput
{
public static class CrossPlatformInputManager
{
public enum ActiveInputMethod
{
Hardware,
Touch
}
private static VirtualInput activeInput;
private static VirtualInput s_TouchInput;
private static VirtualInput s_HardwareInput;
}
}
AxisTouchButton.cs
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityStandardAssets.CrossPlatformInput;
namespace UnityStandardAssets.CrossPlatformInput
{
public class AxisTouchButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
// designed to work in a pair with another axis touch button
// (typically with one having -1 and one having 1 axisValues)
public string axisName = "Horizontal"; // The name of the axis
public float axisValue = 1; // The axis that the value has
public float responseSpeed = 3; // The speed at which the axis touch button responds
public float returnToCentreSpeed = 3; // The speed at which the button will return to its centre
AxisTouchButton m_PairedWith; // Which button this one is paired with
CrossPlatformInputManager.VirtualAxis m_Axis; // A reference to the virtual axis as it is in the cross platform input
void OnEnable()
{
if (!CrossPlatformInputManager.AxisExists(axisName))
{
// if the axis doesnt exist create a new one in cross platform input
m_Axis = new CrossPlatformInputManager.VirtualAxis(axisName);
CrossPlatformInputManager.RegisterVirtualAxis(m_Axis);
}
else
{
m_Axis = CrossPlatformInputManager.VirtualAxisReference(axisName);
}
FindPairedButton();
}
}
}
CrossPlatformInputManager
네임 스페이스 UnityStandardAssets.CrossPlatformInput
을 가지고,하지만 난 유니티 Monodevelop 편집기에서 AxisTouchButton.cs
에 해당 네임 스페이스를 얻을 수 아니에요 스크립트.
P. 두 파일은 서로 다른 디렉토리에 있습니다.
아무나 네임 스페이스에 어떤 문제가 있는지 말해 줄 수 있습니까?
덕분에, Rohit
그러나 OP의 '한 스크립트의 네임 스페이스를 다른 스크립트로 사용할 수 없습니다.'라는 문제가 수정됩니까? – Stefan
@Stefan OP는 이미 * 네임 스페이스가 *있을 때 네임 스페이스를 * 사용 * 할 필요가 없습니다. – HimBromBeere
예, 알 수 있습니다. 그러나 OP의 특정 오류가 발생하는지 궁금합니다. 나는 이것이 단지 호기심에서 벗어 났으므로 단층 현상에 대한 경험이 없다고 말해야 만합니다. 내 생각 엔 OP가 중복 'using'지시어를 사용하고 있지만 네임 스페이스의 클래스에 대한 액세스를 중단하지 않을 것입니다. 또한 OP가 'Unity Monodevelop 편집기에서 AxisTouchButton.cs에서 네임 스페이스를 가져올 수 없습니다.'라고 의미하는 것이 궁금합니다. – Stefan