1

按照 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 的相同命名空间创建一个脚本。我不知道这可能有什么好处或坏处,因为我不太了解命名空间。

我的问题是,我可以在不将我的脚本放在同一个命名空间中的情况下访问这些变量/函数/等吗?如果是这样,怎么做?

我已经自学了编程,如果这对某些人来说太基础了,我深表歉意,谢谢。

4

1 回答 1

1

如果您不想在整个脚本中使用相同的命名空间,则需要在声明变量时显式声明命名空间。

所以,而不是说:

namespace Kudan.AR.Samples
{
    public class SampleApp
    {
        public KudanTracker _kudanTracker; 
    }
}

你会说:

public class SampleApp
{
    public Kudan.AR.KudanTracker _kudanTracker;
}

有关更多信息,我建议查找如何使用 Namespaces

于 2016-07-26T09:03:04.923 回答