Ejemplo n.º 1
0
    // Private
    //private Camera _camera = null;

    private void Start()
    {
        instance = this;
        gameObject.SetActive(false);

        //_camera = GetComponentInChildren<Camera>();
    }
Ejemplo n.º 2
0
    // Use this for initialization
    IEnumerator Start()
    {
        switch (simulationMode)
        {
        case SimulationMode.A:
            yield return(LoadGalaxyMapRoutine("GalaxyMapA"));

            break;

        case SimulationMode.B:
            yield return(LoadGalaxyMapRoutine("GalaxyMapB"));

            break;

        case SimulationMode.C:
            yield return(LoadGalaxyMapRoutine("GalaxyMapC"));

            break;
        }

        GalaxyMapNode defaultNode = GalaxyMapVisual.GetDefaultNode();

        if (defaultNode == null)
        {
            defaultNode = FindObjectOfType <GalaxyMapNode>();
        }
        yield return(LoadSolarSystemSceneRoutine(defaultNode.name));

        ship = Instantiate(shipPrefab, transform).GetComponent <Ship>();
        ship.Setup(this);

        StartingLocation startingLocation = FindObjectOfType <StartingLocation>();

        externalCamera = Instantiate(externalCameraPrefab, transform).GetComponent <ExternalCamera>();
        externalCamera.Setup(ship.transform);

        DynamicObjectsRoot = new GameObject("DynamicObjectsRoots").transform;
        DynamicObjectsRoot.SetParent(transform);
    }
Ejemplo n.º 3
0
        public override void Open()
        {
            if (Application.platform != RuntimePlatform.Android && Application.platform != RuntimePlatform.IPhonePlayer)
            {
                throw new UIPopupException(typeof(CustomCameraSource) + " not available under " + Application.platform);
            }
            willOpen = true;
            CameraDevice.requestPermissions(EasyARController.Scheduler, (Action <PermissionStatus, string>)((status, msg) =>
            {
                if (!willOpen)
                {
                    return;
                }
#if !UNITY_EDITOR && UNITY_ANDROID
                externalCamera = new AndroidJavaObject("com.example.externalcamera.ExternalCameraSample");
                externalCamera.Call <bool>("open");

                cameraCallback = new CameraCallback(dataWrapper =>
                {
                    if (sink == null)
                    {
                        return;
                    }

                    var byteArray    = dataWrapper.Get <AndroidJavaObject>("Buffer");
                    var jniByteArray = byteArray.GetRawObject();

                    var buffer       = JniUtility.wrapByteArray(jniByteArray, true, () => { byteArray.Dispose(); });
                    var format       = (PixelFormat)externalCamera.Call <int>("getPixelFormat");
                    var param        = dataWrapper.Get <AndroidJavaObject>("camParams");
                    int orientation  = param.Call <int>("getOrientation");
                    int cameraType   = param.Call <int>("getCameraType");
                    double timestamp = param.Call <long>("getTimestamp") * 1e-9;
                    var imageWidth   = param.Call <int>("getWidth");
                    var imageHeight  = param.Call <int>("getHeight");
                    var imageSize    = new Vector2(imageWidth, imageHeight);
                    HandleSink(buffer, format, imageSize, orientation, cameraType, timestamp);
                });
#elif !UNITY_EDITOR && UNITY_IOS
                externalCamera = new ExternalCamera();
                externalCamera.open();

                cameraCallback = (data, len) =>
                {
                    var buffer      = Buffer.wrap(data, len, () => { });
                    var format      = PixelFormat.YUV_NV12;
                    var orientation = externalCamera.getOrientation();
                    var cameraType  = externalCamera.getCameraType();
                    var imageWidth  = externalCamera.getImageWidth();
                    var imageHeight = externalCamera.getImageHeight();
                    var timestamp   = externalCamera.getTimestamp();
                    var imageSize   = new Vector2(imageWidth, imageHeight);
                    HandleSink(buffer, format, imageSize, orientation, cameraType, timestamp);
                };
#endif
                if (enabled)
                {
                    OnEnable();
                }
            }));
        }