遵循Kudan的SampleApp脚本:
using UnityEngine;
using System.Collections;
namespace Kudan.AR.Samples
{
/// <summary>
/// Script used in the Kudan Samples. Provides functions that switch between different tracking methods and start abitrary tracking.
/// </summary>
public class SampleApp : MonoBehaviour
{
public KudanTracker _kudanTracker; // The tracker to be referenced in the inspector. This is the Kudan Camera object.
public TrackingMethodMarker _markerTracking; // The reference to the marker tracking method that lets the tracker know which method it is using
public TrackingMethodMarkerless _markerlessTracking; // The reference to the markerless tracking method that lets the tracker know which method it is using
public void MarkerClicked()
{
_kudanTracker.ChangeTrackingMethod(_markerTracking); // Change the current tracking method to marker tracking
}
public void MarkerlessClicked()
{
_kudanTracker.ChangeTrackingMethod(_markerlessTracking); // Change the current tracking method to markerless tracking
}
public void StartClicked()
{
// from the floor placer.
Vector3 floorPosition; // The current position in 3D space of the floor
Quaternion floorOrientation; // The current orientation of the floor in 3D space, relative to the device
_kudanTracker.FloorPlaceGetPose(out floorPosition, out floorOrientation); // Gets the position and orientation of the floor and assigns the referenced Vector3 and Quaternion those values
_kudanTracker.ArbiTrackStart(floorPosition, floorOrientation); // Starts markerless tracking based upon the given floor position and orientations
}
}
}要访问Kudan的函数/事件/变量,我需要使用相同的Kudan名称空间创建脚本。我不知道这会有什么好处或缺点,因为我对名称空间不太了解。
我的问题是,我是否可以访问这些变量/函数/etc,而无需在同一个名称空间中创建脚本?如果是这样的话,是怎么做的?
我已经自学了编程,所以如果这对一些人来说太基本的话,我很抱歉,谢谢你。
发布于 2016-07-26 09:03:04
如果不希望在整个脚本中使用相同的命名空间,则需要在声明变量时显式地声明名称空间。
所以,不要说:
namespace Kudan.AR.Samples
{
public class SampleApp
{
public KudanTracker _kudanTracker;
}
}你会说:
public class SampleApp
{
public Kudan.AR.KudanTracker _kudanTracker;
}要了解更多信息,我建议查找如何使用命名空间。
https://stackoverflow.com/questions/38585053
复制相似问题