コード例 #1
0
        /// <summary>
        /// Generates an interactable from primitives and assigns a select action.
        /// </summary>
        /// <param name="interactableObject"></param>
        /// <param name="interactable"></param>
        /// <param name="translateTargetObject"></param>
        /// <param name="selectActionDescription"></param>
        private void AssembleInteractableButton(out GameObject interactableObject, out Interactable interactable, out Transform translateTargetObject, string selectActionDescription = "Select")
        {
            // Assemble an interactable out of a set of primitives
            // This will be the button housing
            interactableObject      = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
            interactableObject.name = "RuntimeInteractable";
            interactableObject.transform.position    = new Vector3(0.05f, 0.05f, 0.625f);
            interactableObject.transform.localScale  = new Vector3(0.15f, 0.025f, 0.15f);
            interactableObject.transform.eulerAngles = new Vector3(90f, 0f, 180f);

            // This will be the part that gets scaled
            GameObject childObject = GameObject.CreatePrimitive(PrimitiveType.Cylinder);

            childObject.GetComponent <Renderer>().material.color = Color.blue;
            childObject.transform.parent        = interactableObject.transform;
            childObject.transform.localScale    = new Vector3(0.9f, 1f, 0.9f);
            childObject.transform.localPosition = new Vector3(0f, 1.5f, 0f);
            childObject.transform.localRotation = Quaternion.identity;
            // Only use a collider on the main object
            GameObject.Destroy(childObject.GetComponent <Collider>());

            translateTargetObject = childObject.transform;

            // Add an interactable
            interactable = interactableObject.AddComponent <Interactable>();

#if UNITY_EDITOR
            // Find our states and themes via the asset database
            Theme  cylinderTheme = ScriptableObjectExtensions.GetAllInstances <Theme>().FirstOrDefault(profile => profile.name.Equals($"CylinderTheme"));
            States defaultStates = ScriptableObjectExtensions.GetAllInstances <States>().FirstOrDefault(profile => profile.name.Equals($"DefaultInteractableStates"));

            interactable.States = defaultStates;
            InteractableProfileItem profileItem = new InteractableProfileItem();
            profileItem.Themes = new System.Collections.Generic.List <Theme>()
            {
                cylinderTheme
            };
            profileItem.HadDefaultTheme = true;
            profileItem.Target          = translateTargetObject.gameObject;

            interactable.Profiles = new System.Collections.Generic.List <InteractableProfileItem>()
            {
                profileItem
            };
            interactable.ForceUpdateThemes();
#endif

            // Set the interactable to respond to the requested input action
            MixedRealityInputAction selectAction = MixedRealityToolkit.InputSystem.InputSystemProfile.InputActionsProfile.InputActions.Where(m => m.Description == selectActionDescription).FirstOrDefault();
            Assert.NotNull(selectAction.Description, "Couldn't find " + selectActionDescription + " input action in input system profile.");
            interactable.InputAction = selectAction;
        }
コード例 #2
0
        /// <summary>
        /// Creates the list of theme instances based on all the theme settings
        /// </summary>
        protected virtual void SetupThemes()
        {
            InteractableProfileItem.ThemeLists lists = InteractableProfileItem.GetThemeTypes();
            runningThemesList      = new List <InteractableThemeBase>();
            runningProfileSettings = new List <ProfileSettings>();
            for (int i = 0; i < Profiles.Count; i++)
            {
                ProfileSettings      profileSettings   = new ProfileSettings();
                List <ThemeSettings> themeSettingsList = new List <ThemeSettings>();
                for (int j = 0; j < Profiles[i].Themes.Count; j++)
                {
                    Theme         theme         = Profiles[i].Themes[j];
                    ThemeSettings themeSettings = new ThemeSettings();
                    if (Profiles[i].Target != null && theme != null)
                    {
                        List <InteractableThemePropertySettings> tempSettings = new List <InteractableThemePropertySettings>();
                        for (int n = 0; n < theme.Settings.Count; n++)
                        {
                            InteractableThemePropertySettings settings = theme.Settings[n];

                            settings.Theme = InteractableProfileItem.GetTheme(settings, Profiles[i].Target, lists);

                            // add themes to theme list based on dimension
                            if (j == dimensionIndex)
                            {
                                runningThemesList.Add(settings.Theme);
                            }

                            tempSettings.Add(settings);
                        }

                        themeSettings.Settings = tempSettings;
                        themeSettingsList.Add(themeSettings);
                    }
                }

                profileSettings.ThemeSettings = themeSettingsList;
                runningProfileSettings.Add(profileSettings);
            }
        }
コード例 #3
0
        /*
         * THEMES
         */

        protected void SetupThemeOptions()
        {
            themeOptions = InteractableProfileItem.GetThemeTypes();
        }
コード例 #4
0
        /*
         * THEMES
         */

        protected void SetupThemeOptions()
        {
            InteractableProfileItem.ThemeLists lists = InteractableProfileItem.GetThemeTypes();
            themeOptions = lists.Names.ToArray();
            themeTypes   = lists.Types.ToArray();
        }