2016-07-26 1 views
1

После SampleApp сценария Kudan в:Доступ Kudan событию, переменные, хотя другой сценарий

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 в функции/событие/переменный Мне нужно создать сценарий, используя те же пространство имен Куданы. Я не знаю, что вверх или вниз это могло иметь, поскольку я не понимаю пространства имён.

Мой вопрос в том, могу ли я получить доступ к этим переменным/функциям/etc, не делая свой скрипт в том же пространстве имен? Если да, то как?

Я изучаю программирование самостоятельно, поэтому извиняюсь, если это кажется слишком важным для некоторых, и спасибо.

ответ

1

Если вы не хотите использовать одно и то же пространство имен по всему сценарию, вам нужно будет явно указать пространство имен при объявлении переменной.

Таким образом, вместо того чтобы сказать:

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

вы бы сказали:

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

Для получения дополнительной информации, я хотел бы предложить глядя how to use Namespaces.

+0

Спасибо, это именно то, что мне нужно! – jFelipe

Смежные вопросы