首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过另一个脚本访问Kudan事件、变量

通过另一个脚本访问Kudan事件、变量
EN

Stack Overflow用户
提问于 2016-07-26 08:44:59
回答 1查看 167关注 0票数 1

遵循Kudan的SampleApp脚本:

代码语言:javascript
复制
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,而无需在同一个名称空间中创建脚本?如果是这样的话,是怎么做的?

我已经自学了编程,所以如果这对一些人来说太基本的话,我很抱歉,谢谢你。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-26 09:03:04

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

所以,不要说:

代码语言:javascript
复制
namespace Kudan.AR.Samples
{
    public class SampleApp
    {
        public KudanTracker _kudanTracker; 
    }
}

你会说:

代码语言:javascript
复制
public class SampleApp
{
    public Kudan.AR.KudanTracker _kudanTracker;
}

要了解更多信息,我建议查找如何使用命名空间

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38585053

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档