1
我想在Unity編輯器中開發一個遊戲。 我無法使用從一個腳本到另一個腳本的名稱空間。 請在下面找到腳本。不能在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
,但我沒能獲得該命名空間中AxisTouchButton.cs
在Unity MonoDevelop的編輯器。
P.S. :這兩個文件都位於不同的目錄中。
任何人都可以告訴我這個命名空間有什麼問題嗎?
感謝, 羅希特
但是,它會解決OP的'我不能使用從一個腳本到另一個腳本的命名空間。 – Stefan
@Stefan OP在他/她已經*進入時不需要*使用*命名空間。 – HimBromBeere
是的,我可以看到。但我仍然想知道這是否會導致OP的具體錯誤。我必須說,我沒有任何monodevelop的經驗,所以這只是出於好奇。我的猜測是,儘管OP使用冗餘的'using'指令,它不會中斷對命名空間中類的訪問。我也想知道什麼OP意味着'我無法在Unity Monodevelop編輯器中的AxisTouchButton.cs中獲得該名稱空間' – Stefan