示例#1
0
            private State()
            {
                try
                {
                    // Initialize logging for the plugin.
                    ZPlugin.InitializeLogging();

                    // Initialize the zSpace context.
                    this.Context = new ZContext();

                    // Attempt to retrieve the zSpace display.
                    ZDisplay display = this.Context.DisplayManager.GetDisplay(
                        ZDisplayType.zSpace);

                    // Create and initialize the primary viewport.
                    this.Viewport = this.Context.CreateViewport(
                        (display != null) ? display.Position : Vector2Int.zero);

                    this.IsInitialized = true;
                }
                catch
                {
                    if (Application.isPlaying)
                    {
                        Debug.LogWarning(
                            "Failed to properly initialize the zSpace " +
                            "Provider. Reverting to mock tracker-less, " +
                            "monoscopic 3D.");
                    }

                    this.Dispose();
                }
            }
        ////////////////////////////////////////////////////////////////////////
        // Private Methods
        ////////////////////////////////////////////////////////////////////////

        private string DisplayAttributesAsString(ZDisplay display)
        {
            string attributeString = "";

            foreach (ZDisplayAttribute attribute in
                     Enum.GetValues(typeof(ZDisplayAttribute)))
            {
                attributeString += attribute.ToString() + ": " +
                                   display.GetAttribute(attribute) + "\n";
            }
            return(attributeString);
        }
        ////////////////////////////////////////////////////////////////////////
        // Private Methods
        ////////////////////////////////////////////////////////////////////////

        private void UpdateScreenMetrics()
        {
            // If the display reference profile is not custom, lock
            // the display reference size to the appropriate value.
            if (this._displayReferenceProfile != ZDisplay.Profile.Custom)
            {
                this._displayReferenceSize = ZDisplay.GetSize(
                    this._displayReferenceProfile);

                this._displayReferenceResolution = ZDisplay.GetNativeResolution(
                    this._displayReferenceProfile);
            }

            this._displayReferenceSize = Vector2.Max(
                ZDisplay.MinimumSize, this._displayReferenceSize);

            this._displayReferenceResolution = Vector2Int.Max(
                Vector2Int.one, this._displayReferenceResolution);

            // Update current display information.
            DisplayReferenceSize       = this._displayReferenceSize;
            DisplayReferenceResolution = this._displayReferenceResolution;
            DisplaySize       = CurrentDisplay?.Size ?? this._displayReferenceSize;
            DisplayResolution = CurrentDisplay?.NativeResolution ??
                                this._displayReferenceResolution;

            DisplayMetersPerPixel = new Vector2(
                DisplaySize.x / DisplayResolution.x,
                DisplaySize.y / DisplayResolution.y);

            DisplayScale       = ZDisplay.GetScale(DisplayReferenceSize, DisplaySize);
            DisplayScaleFactor = Mathf.Min(DisplayScale.x, DisplayScale.y);

            // Update current window information.
            if (IsInitialized)
            {
                WindowSizePixels = ZApplicationWindow.Size;
                WindowSize       = WindowSizePixels * DisplayMetersPerPixel;
            }
            else
            {
                WindowSizePixels = DisplayResolution;
                WindowSize       = DisplaySize;
            }
        }
示例#4
0
        ////////////////////////////////////////////////////////////////////////
        // MonoBehaviour Callbacks
        ////////////////////////////////////////////////////////////////////////

        private void Start()
        {
            if (ZProvider.IsInitialized)
            {
                this._stylusTarget = ZProvider.StylusTarget;

                if (ZProvider.CurrentDisplay.Size !=
                    ZDisplay.GetSize(ZDisplay.Profile.Size24InchAspect16x9))
                {
                    Debug.LogWarning("AIO model hardware not detected.\n " +
                                     "Stylus vibration and LED light feedback will not " +
                                     "be experienced.");
                }
            }
            else
            {
                Debug.LogWarning("ZProvider can not initialize.\n Stylus" +
                                 "LED light feedback will not be experienced.");

                Destroy(this);
            }
        }