private void OnEnable()
    {
        this.OnOrientationChange(
            VLDetectScreenChangeBehaviour.GetOrientation(this.gameObject));
        VLDetectScreenChangeBehaviour.OnOrientationChange += OnOrientationChange;

        VLWorkerBehaviour.OnExtrinsicData += OnExtrinsicData;
        VLWorkerBehaviour.OnIntrinsicData += OnIntrinsicData;
    }
    public static ScreenOrientation GetOrientation(GameObject go)
    {
        VLDetectScreenChangeBehaviour behaviour = FindInstance(go);

        if (behaviour != null)
        {
            return(behaviour.GetOrientation());
        }
        return(Screen.orientation);
    }
    public static VLDetectScreenChangeBehaviour FindInstance(GameObject go)
    {
        // Look for the VLDetectScreenChangeBehaviour at the given GameObject
        // first
        if (go != null)
        {
            VLDetectScreenChangeBehaviour behaviour =
                go.GetComponent <VLDetectScreenChangeBehaviour>();
            if (behaviour != null)
            {
                return(behaviour);
            }
        }

        // Try to find it anywhere in the scene
        return(UnityEngine.Object.FindObjectOfType <VLDetectScreenChangeBehaviour>());
    }
Exemple #4
0
    private void OnEnable()
    {
        // Get a handle to the current object and make sure, that the object
        // doesn't get deleted by the garbage collector. We then use this
        // handle as client data for the native callbacks. This allows us to
        // retrieve the current address of the actual object during the
        // callback execution. GCHandleType.Pinned is not necessary, because we
        // are accessing the address only through the handle object, which gets
        // stored in a global handle table.
        this.gcHandle = GCHandle.Alloc(this);

        this.OnOrientationChange(
            VLDetectScreenChangeBehaviour.GetOrientation(this.gameObject));
        VLDetectScreenChangeBehaviour.OnOrientationChange += OnOrientationChange;

        // Get the worker from the object with the WorkerBehaviour component
        this.InitWorkerReference();

        this.Subscribe();
    }
Exemple #5
0
    private void OnEnable()
    {
        // Unity returns an unknown screen orientation on iOS for some reason.
        // Therefore we check if the value is valid here.
        ScreenOrientation orientation =
            VLDetectScreenChangeBehaviour.GetOrientation(this.gameObject);

        if (orientation == ScreenOrientation.Portrait ||
            orientation == ScreenOrientation.PortraitUpsideDown ||
            orientation == ScreenOrientation.LandscapeLeft ||
            orientation == ScreenOrientation.LandscapeRight)
        {
            this.OnOrientationChange(orientation);
        }
        this.OnScreenSizeChange(Screen.width, Screen.height);

        VLDetectScreenChangeBehaviour.OnOrientationChange += OnOrientationChange;
        VLDetectScreenChangeBehaviour.OnSizeChange        += OnScreenSizeChange;

        VLWorkerBehaviour.OnImage += OnImage;
        this.backgroundGO.SetActive(true);
    }
Exemple #6
0
 private void OnEnable()
 {
     this.OnOrientationChange(
         VLDetectScreenChangeBehaviour.GetOrientation(this.gameObject));
     VLDetectScreenChangeBehaviour.OnOrientationChange += OnOrientationChange;
 }