Ejemplo n.º 1
0
        private static RectTransform MakeText(Transform parent, string name, Vector3 position, float width, float height, Vector3 scale, int fontSize, TextAnchor alignment, Color textColor)
        {
            var text = parent.Ensure <RectTransform>(name);

            if (text.IsNew)
            {
                text.SetAnchors(0.5f * Vector2.one, 0.5f * Vector2.one)
                .SetPivot(0.5f * Vector2.one)
                .SetScale(scale)
                .SetPosition(position)
                .SetSize(width, height);
            }

            var textTxt = text
                          .Ensure <CanvasRenderer>()
                          .Ensure <Text>();

            if (textTxt.IsNew)
            {
                textTxt.Value.font                 = ResourceExt.LoadAsset <Font>("Assets/PicoMobileSDK/Pvr_Controller/MicrosoftYaHeiGB.ttf");
                textTxt.Value.fontStyle            = FontStyle.Normal;
                textTxt.Value.fontSize             = fontSize;
                textTxt.Value.lineSpacing          = 1;
                textTxt.Value.supportRichText      = true;
                textTxt.Value.alignment            = alignment;
                textTxt.Value.alignByGeometry      = false;
                textTxt.Value.horizontalOverflow   = HorizontalWrapMode.Wrap;
                textTxt.Value.verticalOverflow     = VerticalWrapMode.Truncate;
                textTxt.Value.resizeTextForBestFit = false;
                textTxt.Value.color                = textColor;
                textTxt.Value.raycastTarget        = true;
            }

            return(text);
        }
Ejemplo n.º 2
0
        public override void Install(bool reset)
        {
            base.Install(reset);

#if UNITY_EDITOR
            if (ARBackgroundMaterial == null || reset)
            {
                ARBackgroundMaterial = ResourceExt.EditorLoadAsset <Material>("Assets/GoogleARCore/SDK/Materials/ARBackground.mat");
            }
#endif

            if (arCoreSession == null)
            {
                arCoreSession = this.Ensure <ARCoreSession>().Value;
                arCoreSession.SessionConfig = ScriptableObject.CreateInstance <ARCoreSessionConfig>();
                arCoreSession.SessionConfig.MatchCameraFramerate = true;
            }

            if (bgRenderer == null)
            {
                bgRenderer = this.Ensure <ARCoreBackgroundRenderer>().Value;
                bgRenderer.BackgroundMaterial = ARBackgroundMaterial;
            }

            if (poseDriver == null)
            {
                poseDriver = this.Ensure <TrackedPoseDriver>().Value;
                poseDriver.SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRDevice, TrackedPoseDriver.TrackedPose.ColorCamera);
                poseDriver.trackingType         = TrackedPoseDriver.TrackingType.RotationAndPosition;
                poseDriver.updateType           = TrackedPoseDriver.UpdateType.BeforeRender;
                poseDriver.UseRelativeTransform = true;
            }
        }
Ejemplo n.º 3
0
        private static void MakeResetPanel(Transform parent)
        {
            var panel = MakePanel(
                parent,
                "ResetPanel",
                Vector3.zero,
                Quaternion.identity,
                3 * Vector3.forward,
                400, 400,
                new Color(27f / 255, 27f / 255, 27f / 255, 1));

            panel.Ensure <GraphicRaycaster>();

            MakeText(
                panel,
                "toast",
                new Vector3(3, 88, 0),
                340, 170,
                Vector3.one,
                25, TextAnchor.UpperLeft,
                Color.white);

            MakeImage(
                panel,
                "Image",
                -82 * Vector3.up,
                200, 200,
                ResourceExt.LoadAsset <Sprite>("Assets/PicoMobileSDK/Pvr_Controller/Texture/0.8M.png"),
                Image.Type.Simple);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a new hand pointer object for an interaction source that hasn't yet been seen.
        /// </summary>
        private static T MakeMotionController <T>(Func <string, T> MakePointer, Hand hand)
            where T : AbstractHandedPointer <HandIDType, ButtonIDType, ConfigType, HapticType>
        {
            var pointer = MakePointer(PointerConfig.MakePointerName(hand));

#if UNITY_EDITOR
            pointer.motionFilter = ResourceExt.EditorLoadAsset <KalmanMotionFilter>("Assets/Juniper/Assets/Prefabs/Filters/handTrackingKalmanFilter.asset");
#endif
            pointer.Hand = hand;
            return(pointer);
        }
Ejemplo n.º 5
0
        private static void MakeSafeArea(Transform parent)
        {
#if UNITY_EDITOR
            var safeArea = parent.Find("SafeArea2");
            if (safeArea == null)
            {
                safeArea      = Instantiate(ResourceExt.EditorLoadAsset <GameObject>("Assets/PicoMobileSDK/Pvr_UnitySDK/Resources/Cylinder01.FBX"), parent).transform;
                safeArea.name = "SafeArea2";
                safeArea.Deactivate();
            }
#endif
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Installs necessary components and initializes their default values.
        /// </summary>
        public void Install(bool reset)
        {
#if UNITY_MODULES_AUDIO
#if UNITY_EDITOR
            if (reset)
            {
                fadeOutSound = ResourceExt.EditorLoadAsset <AudioClip>("Assets/Juniper/Assets/Audio/Star Trek/hologram_off_2.mp3");
            }
#endif

            aud             = this.Ensure <AudioSource>();
            aud.playOnAwake = false;
            aud.clip        = fadeOutSound;
#endif
        }
Ejemplo n.º 7
0
        private void SetupSystemInterface()
        {
            systemUserInterface = transform.Query("/SystemUserInterface");
#if UNITY_EDITOR
            if (systemUserInterface == null)
            {
                var prefab = ResourceExt.EditorLoadAsset <GameObject>("Assets/Juniper/Assets/Prefabs/UI/SystemUserInterface.prefab");
                systemUserInterface      = Instantiate(prefab).transform;
                systemUserInterface.name = "SystemUserInterface";
            }
#endif

            loadingBar = systemUserInterface.Query <LoadingBar>("LoadingBar");

            splash = systemUserInterface.Query <UnityImage>("Canvas/SplashImage");
        }
Ejemplo n.º 8
0
        private static RectTransform MakePanel(Transform parent, string containerName, Vector3 containerPosition, Quaternion containerRotation, Vector3 position, float width, float height, Color imageColor)
        {
            var container = parent.Ensure <Transform>(containerName);

            if (container.IsNew)
            {
                container.transform.position = containerPosition;
                container.transform.rotation = containerRotation;
            }

            var panel       = container.Ensure <RectTransform>("Panel");
            var panelCanvas = panel.Ensure <Canvas>();

            if (panelCanvas.IsNew)
            {
                panelCanvas.Value.renderMode = RenderMode.WorldSpace;
            }

            if (panel.IsNew)
            {
                panel.SetAnchors(Vector2.zero, Vector2.one)
                .SetPivot(0.5f * Vector2.one)
                .SetScale(0.0043f * Vector3.one)
                .SetSize(width, height)
                .SetPosition(position);
            }

            var panelImage = panel
                             .Ensure <CanvasRenderer>()
                             .Ensure <Image>();

            if (panelImage.IsNew)
            {
#if UNITY_EDITOR
                panelImage.Value.sprite = ResourceExt.EditorLoadAsset <Sprite>("UI/Skin/Background.psd");
#endif
                panelImage.Value.color         = imageColor;
                panelImage.Value.raycastTarget = true;
                panelImage.Value.type          = Image.Type.Sliced;
                panelImage.Value.fillCenter    = true;
            }

            container.Deactivate();

            return(panel);
        }
Ejemplo n.º 9
0
        public virtual void Install(bool reset)
        {
#if UNITY_EDITOR
            if (pointerPrefab == null)
            {
                pointerPrefab = ResourceExt.EditorLoadAsset <GameObject>("Assets/Juniper/Assets/Prefabs/Rigs/DiskProbe2018.2.prefab");
            }

            if (laserPointerNormalMaterial == null)
            {
                laserPointerNormalMaterial = ResourceExt.EditorLoadAsset <Material>("Assets/Juniper/Assets/Materials/LaserPointer_White.mat");
            }

            if (laserPointerEnabledMaterial == null)
            {
                laserPointerEnabledMaterial = ResourceExt.EditorLoadAsset <Material>("Assets/Juniper/Assets/Materials/LaserPointer_Green.mat");
            }

            if (laserPointerDisabledMaterial == null)
            {
                laserPointerDisabledMaterial = ResourceExt.EditorLoadAsset <Material>("Assets/Juniper/Assets/Materials/LaserPointer_Red.mat");
            }
#endif

            Find.Any(out stage);

            stage.Install(reset);
            stage.IndependentHead = HasFloorPosition;

            Gaze   = MakePointer <GazePointer>(stage.Head, "GazePointer");
            Mouse  = MakePointer <Mouse>(stage.Head, "Mouse");
            Helper = MakePointer <NetworkPointer>(stage.Hands, "Network");

            Touches = new TouchPoint[10];
            for (var i = 0; i < Touches.Length; ++i)
            {
                Touches[i]          = MakePointer <TouchPoint>(stage.Head, $"Touches/TouchPoint{i.ToString()}");
                Touches[i].fingerID = i;
            }

            Controllers = MotionController.MakeControllers(MakeHandPointer <MotionController>);
            Hands       = HandTracker.MakeControllers(MakeHandPointer <HandTracker>);

            Voice = this.FindClosest <KeywordRecognizer>();
        }
Ejemplo n.º 10
0
        private void SetupFader(bool reset)
        {
#if UNITY_EDITOR
            if (sceneFaderMaterial == null || reset)
            {
                sceneFaderMaterial = ResourceExt.EditorLoadAsset <Material>("Assets/Juniper/Assets/Materials/FaderMaterial.mat");
            }
#endif

            var fader = FadeTransition.Ensure(DisplayManager.MainCamera.transform);
            if (fader.IsNew || reset)
            {
                fader.GetComponent <Renderer>()
                .SetMaterial(sceneFaderMaterial);
                fader.transform.localPosition = Mathf.Max(0.5f, 1.2f * DisplayManager.MainCamera.nearClipPlane) * Vector3.forward;
                fader.transform.localScale    = 2 * Vector3.one;
            }
        }
Ejemplo n.º 11
0
        public override void Install(bool reset)
        {
            base.Install(reset);

            this.Ensure <GvrControllerInput>();
            this.Ensure <GvrEditorEmulator>();

#if UNITY_EDITOR
            if (!Find.Any <>(out InstantPreviewHelper ip))
            {
                var ipGo = ResourceExt.EditorLoadAsset <GameObject>(
                    "Assets/GoogleVR/Prefabs/InstantPreview/GvrInstantPreviewMain.prefab");
                if (ipGo != null)
                {
                    UnityEditor.PrefabUtility.InstantiatePrefab(ipGo);
                }
            }
#endif
        }
Ejemplo n.º 12
0
        private static void MaybeAddArrayElement(string arrayName, string[] defaultValues, string value)
        {
            if (!defaultValues.Contains(value))
            {
                var  tagManager = ResourceExt.EditorLoadAsset("ProjectSettings/TagManager.asset");
                var  arrayProp  = tagManager.FindProperty(arrayName);
                bool found      = false;
                for (int i = 0; i < arrayProp.arraySize && !found; i++)
                {
                    var arrayElement = arrayProp.GetArrayElementAtIndex(i);
                    found = arrayElement.stringValue == value;
                }

                if (!found)
                {
                    var n = arrayProp.arraySize;
                    arrayProp.InsertArrayElementAtIndex(n);
                    var newAarrayElement = arrayProp.GetArrayElementAtIndex(n);
                    newAarrayElement.stringValue = value;
                    tagManager.ApplyModifiedProperties();
                }
            }
        }
Ejemplo n.º 13
0
        private static void MakeSafeToast(Transform parent)
        {
            var panel = MakePanel(
                parent,
                "SafeToast",
                Vector3.zero,
                Quaternion.identity,
                Vector3.zero,
                400, 400,
                new Color(27f / 255, 27f / 255, 27f / 255, 1));

            MakeText(
                panel,
                "title",
                153 * Vector3.up,
                415, 50,
                Vector3.one,
                30, TextAnchor.MiddleCenter,
                new Color(1f, 0.57f, 0f));

            MakeText(
                panel,
                "Text",
                -8 * Vector3.up,
                350, 250,
                Vector3.one,
                25, TextAnchor.UpperLeft,
                Color.white);

            MakeImage(
                panel,
                "Image",
                -82 * Vector3.up,
                200, 200,
                ResourceExt.LoadAsset <Sprite>("Assets/PicoMobileSDK/Pvr_Controller/Texture/0.8M.png"),
                Image.Type.Simple);
        }
Ejemplo n.º 14
0
        public List <ResourceExt> GetResources(ResourceExt resourceExt, int page, int pageSize)
        {
            resourceExt.RoleItemId = resourceExt.RoleItemId;
            resourceExt.Status     = resourceExt.Status.ToLikeEncodedParameter();

            string sql = "";

            if (page == -1 && pageSize == -1)
            {
                sql = @"SELECT r.ResourceID as ResourceID, r.Name as Name, r.Status as Status, rRole.RoleItemID as RoleItemID, r.ResourceContent
                            From Resource r inner join (select rir.ResourceID,ri.RoleItemID as RoleItemID,rir.CreationDate from RoleItemResource rir inner join RoleItem ri on rir.RoleItemID = ri.RoleItemID) as rRole
                            on r.ResourceID = rRole.ResourceID #RESOURCESTATUSFILTER# #RESOURCEROLEFILTER# order by rRole.CreationDate";
            }
            else
            {
                sql = @"SELECT r.ResourceID as ResourceID, r.Name as Name, r.Status as Status, rRole.RoleItemID as RoleItemID, r.ResourceContent
                            From Resource r inner join (select rir.ResourceID,ri.RoleItemID as RoleItemID,rir.CreationDate from RoleItemResource rir inner join RoleItem ri on rir.RoleItemID = ri.RoleItemID) as rRole
                            on r.ResourceID = rRole.ResourceID #RESOURCESTATUSFILTER# #RESOURCEROLEFILTER# order by rRole.CreationDate OFFSET @FromPage ROWS FETCH NEXT @PageSize ROWS ONLY";
            }

            //RESOURCESTATUSFILTER
            string str = "";

            if (!string.IsNullOrEmpty(resourceExt.Status))
            {
                sql = sql.Replace("#RESOURCESTATUSFILTER#", "where r.Status like @Status");
                str = "and";
            }
            else
            {
                sql = sql.Replace("#RESOURCESTATUSFILTER#", "");
            }


            //RESOURCEROLEFILTER
            if (resourceExt.RoleItemId != 0)
            {
                if (string.IsNullOrEmpty(str))
                {
                    str = "where";
                }
                sql = sql.Replace("#RESOURCEROLEFILTER#", str + " rRole.RoleItemID = @RoleItemId");
            }
            else
            {
                sql = sql.Replace("#RESOURCEROLEFILTER#", "");
            }

            //page size check
            if (pageSize <= 0 || pageSize > 100)
            {
                pageSize = 20;
            }

            int from = page * pageSize;

            return(AppDbContext.Instance.Connection.Query <ResourceExt>(sql, new
            {
                FromPage = from,
                PageSize = pageSize,
                Status = resourceExt.Status,
                RoleItemId = resourceExt.RoleItemId
                             //RoleItemName = profileExt.RoleItemName
            }, AppDbContext.Instance.Transaction).ToList());
        }
Ejemplo n.º 15
0
 public virtual List <ResourceExt> GetMyResources(ResourceExt resourceExt)
 {
     return(resourceRepo.GetResources(resourceExt, -1, -1));
 }
Ejemplo n.º 16
0
 public virtual List <ResourceExt> GetResources(ResourceExt resourceExt, int page = 0, int pageSize = 10)
 {
     return(resourceRepo.GetResources(resourceExt, page, pageSize));
 }
Ejemplo n.º 17
0
        private static PooledComponent <Button> MakeSafePanel2(Transform parent, PooledComponent <Pvr_UnitySDKManager> sdkMgr)
        {
            var panel = MakePanel(
                parent,
                "SafePanel2",
                Vector3.zero,
                Quaternion.identity,
                3 * Vector3.forward,
                400, 400,
                new Color(27f / 255, 27f / 255, 27f / 255, 1));

            panel.Ensure <GraphicRaycaster>();

            MakeText(
                panel,
                "Title",
                159 * Vector3.up,
                200, 45,
                Vector3.one,
                30, TextAnchor.MiddleCenter,
                new Color(1f, 0.57f, 0f));

            MakeText(
                panel,
                "toast2",
                5.3f * Vector3.up,
                359, 132,
                Vector3.one,
                25, TextAnchor.MiddleCenter,
                Color.white);

            var forceQuit = MakeImage(
                panel,
                "forcequitBtn",
                -82 * Vector3.up,
                200, 35,
                ResourceExt.LoadAsset <Sprite>("Assets/PicoMobileSDK/Pvr_Controller/Texture/Bt_background_long1.png"),
                Image.Type.Sliced);

            var forceQuitButton = forceQuit.Ensure <Button>();

            if (forceQuitButton.IsNew)
            {
                forceQuitButton.Value.interactable  = true;
                forceQuitButton.Value.transition    = Selectable.Transition.ColorTint;
                forceQuitButton.Value.targetGraphic = forceQuit.GetComponent <Image>();
                forceQuitButton.Value.colors        = new ColorBlock
                {
                    normalColor      = Color.white,
                    highlightedColor = Color.blue,
                    pressedColor     = Color.red,
                    disabledColor    = Color.grey,
                    colorMultiplier  = 1,
                    fadeDuration     = 0.1f
                };
                forceQuitButton.Value.navigation = new Navigation
                {
                    mode = Navigation.Mode.Automatic
                };
            }

            var forceQuitText = forceQuit
                                .Ensure <RectTransform>("Text")
                                .Ensure <Text>();

            if (forceQuitText.IsNew)
            {
                forceQuitText.Value.font                 = ResourceExt.LoadAsset <Font>("Assets/PicoMobileSDK/Pvr_Controller/MicrosoftYaHeiGB.ttf");
                forceQuitText.Value.fontStyle            = FontStyle.Normal;
                forceQuitText.Value.fontSize             = 20;
                forceQuitText.Value.lineSpacing          = 1;
                forceQuitText.Value.supportRichText      = true;
                forceQuitText.Value.alignment            = TextAnchor.MiddleCenter;
                forceQuitText.Value.alignByGeometry      = false;
                forceQuitText.Value.horizontalOverflow   = HorizontalWrapMode.Wrap;
                forceQuitText.Value.verticalOverflow     = VerticalWrapMode.Truncate;
                forceQuitText.Value.resizeTextForBestFit = false;
                forceQuitText.Value.color                = new Color(50f / 255, 50f / 255, 50f / 255);
                forceQuitText.Value.raycastTarget        = true;
            }

            if (forceQuitButton.IsNew || sdkMgr.IsNew)
            {
                forceQuitButton.Value.onClick.AddListener(sdkMgr.Value.SixDofForceQuit);
            }

            return(forceQuitButton);
        }