protected GameObject Panel(GameObject parent, string name)
        {
            PanelContainerProfile profile = Defaults.GetProfile(panelContainerProfile);
            PanelContainerFactory factory = Undoable.AddComponent <PanelContainerFactory>(disposable);

            factory.parent                = parent;
            factory.containerName         = name;
            factory.panelContainerProfile = profile;
            GameObject panel = factory.Generate();

            PanelProfile  subPanelProfile = CreateSubPanelProfile(panel);
            StandardPanel standardPanel   = Undoable.AddComponent <StandardPanel>(panel);

            standardPanel.panelProfile = subPanelProfile;
            standardPanel.grabTarget   = keyboard.transform;

#if VRTK
            CreateThis_VRTK_Interactable interactable = Undoable.AddComponent <CreateThis_VRTK_Interactable>(panel);
            CreateThis_VRTK_GrabAttach   grabAttach   = Undoable.AddComponent <CreateThis_VRTK_GrabAttach>(panel);
            interactable.isGrabbable = true;
            interactable.grabAttachMechanicScript = grabAttach;
#endif

            Rigidbody rigidbody = Undoable.AddComponent <Rigidbody>(panel);
            rigidbody.useGravity  = false;
            rigidbody.isKinematic = true;

            return(panel);
        }
Esempio n. 2
0
        protected GameObject Label(GameObject parent, string name, string text)
        {
            PanelContainerProfile pcProfile = Defaults.GetProfile(panelContainerProfile);
            ButtonProfile         profile   = Defaults.GetMomentaryButtonProfile(momentaryButtonProfile);
            GameObject            label     = EmptyChild(parent, name);

            label.transform.localScale = profile.labelScale;
            Vector3 localPosition = new Vector3(0, 0, profile.labelZ);

            label.transform.localPosition = localPosition;
            TextMesh textMesh = Undoable.AddComponent <TextMesh>(label);

            textMesh.text          = text;
            textMesh.fontSize      = profile.fontSize;
            textMesh.color         = profile.fontColor;
            textMesh.characterSize = pcProfile.labelCharacterSize;
            textMesh.anchor        = TextAnchor.MiddleCenter;

            BoxCollider boxCollider = Undoable.AddComponent <BoxCollider>(label);

            UpdateBoxColliderFromTextMesh updateBoxCollider = Undoable.AddComponent <UpdateBoxColliderFromTextMesh>(label);

            updateBoxCollider.textMesh    = textMesh;
            updateBoxCollider.boxCollider = boxCollider;
            return(label);
        }
Esempio n. 3
0
        protected GameObject Panel(GameObject parent, string name)
        {
            PanelContainerProfile profile   = Defaults.GetProfile(panelContainerProfile);
            FilePanelProfile      fpProfile = Defaults.GetProfile(filePanelProfile);
            PanelContainerFactory factory   = Undoable.AddComponent <PanelContainerFactory>(disposable);

            factory.parent                = parent;
            factory.containerName         = name;
            factory.panelContainerProfile = profile;
            GameObject panel = factory.Generate();

            filePanel                         = AddFilePanel(panel);
            filePanel.grabTarget              = filePanelContainerInstance.transform;
            filePanel.folderPrefab            = fpProfile.folderPrefab;
            filePanel.kineticScrollItemPrefab = kineticScrollerItem;
            filePanel.height                  = fpProfile.scrollerHeight;
            filePanel.searchPattern           = fpProfile.searchPattern;
            filePanel.panelProfile            = panelProfile;

#if VRTK
            CreateThis_VRTK_Interactable interactable = Undoable.AddComponent <CreateThis_VRTK_Interactable>(panel);
            CreateThis_VRTK_GrabAttach   grabAttach   = Undoable.AddComponent <CreateThis_VRTK_GrabAttach>(panel);
            interactable.isGrabbable = true;
            interactable.grabAttachMechanicScript = grabAttach;
#endif

            drives = Undoable.AddComponent <Drives>(panel);

            Rigidbody rigidbody = Undoable.AddComponent <Rigidbody>(panel);
            rigidbody.useGravity  = false;
            rigidbody.isKinematic = true;

            return(panel);
        }
        protected void SetKeyboardButtonPosition(GameObject button)
        {
            PanelContainerProfile profile = Defaults.GetProfile(panelContainerProfile);
            Vector3 localPosition         = button.transform.localPosition;

            localPosition.z = profile.buttonZ;
            button.transform.localPosition = localPosition;
        }
        protected GameObject Column(GameObject parent)
        {
            PanelContainerProfile  profile = Defaults.GetProfile(panelContainerProfile);
            ColumnContainerFactory factory = Undoable.AddComponent <ColumnContainerFactory>(disposable);

            factory.parent  = parent;
            factory.padding = profile.padding;
            factory.spacing = profile.spacing;
            return(factory.Generate());
        }
        protected GameObject Row(GameObject parent, string name = null, TextAlignment alignment = TextAlignment.Center)
        {
            PanelContainerProfile profile = Defaults.GetProfile(panelContainerProfile);
            RowContainerFactory   factory = Undoable.AddComponent <RowContainerFactory>(disposable);

            factory.containerName = name;
            factory.parent        = parent;
            factory.padding       = profile.padding;
            factory.spacing       = profile.spacing;
            factory.alignment     = alignment;
            return(factory.Generate());
        }
Esempio n. 7
0
        protected override void AddContainer(GameObject target)
        {
            PanelContainer        container = Undoable.AddComponent <PanelContainer>(target);
            PanelContainerProfile profile   = Defaults.GetProfile(panelContainerProfile);

            if (containerName == null)
            {
                target.name = "Panel";
            }
            else
            {
                target.name = containerName;
            }
            container.minWidth  = profile.minWidth;
            container.minHeight = profile.minHeight;
        }
Esempio n. 8
0
        protected override void CreateContainer()
        {
            if (containerInstance)
            {
                return;
            }
            PanelContainerProfile profile = Defaults.GetProfile(panelContainerProfile);

            containerInstance = Instantiate(profile.panelBody);

#if UNITY_EDITOR
            Undo.RegisterCreatedObjectUndo(containerInstance, "Created Container");
#endif
            containerInstance.SetActive(true);
            containerInstance.transform.localScale    = profile.bodyScale;
            containerInstance.transform.parent        = parent.transform;
            containerInstance.transform.localPosition = Vector3.zero;
            containerInstance.transform.localRotation = Quaternion.identity;
            if (containerName == null)
            {
                containerInstance.name = "Container";
            }

            BoxCollider boxCollider = containerInstance.GetComponent <BoxCollider>(); // this comes from the cube/prefab the panel is created from
            if (!boxCollider)
            {
                Debug.Log("no box collider");
            }
            boxCollider.isTrigger = true;

            MeshRenderer meshRenderer = containerInstance.GetComponent <MeshRenderer>();
            meshRenderer.materials = new Material[1] {
                profile.material
            };

            Selectable selectable = containerInstance.AddComponent <Selectable>();
            selectable.highlightMaterial   = profile.highlight;
            selectable.outlineMaterial     = profile.outline;
            selectable.textColor           = profile.fontColor;
            selectable.unselectedMaterials = new Material[] { profile.material };

            AddContainer(containerInstance);
        }