Пример #1
0
        /// <summary>
        /// Clean out unused instances for the Menu Scene and instantiate the visible and enabled instances
        /// </summary>
        public void RebuildMenuInstances()
        {
            this.DestroyAllInstances();

            IEnumerable <PrefabData> enabledPrefabs = this.Configuration.Scenes.Where(s => s.ShowInMenu).SelectMany(s => s.Prefabs).Where(p => p.Enabled);

            enabledPrefabs.ToList().ForEach(prefab =>
            {
                prefab.Instances?.ForEach(instance =>
                {
                    instance.Instance       = GameObject.Instantiate(prefab.Prefab);
                    instance.Instance.name += "_MenuInstance";
                    instance.Instance.transform.position   = instance.Pose.position;
                    instance.Instance.transform.rotation   = instance.Pose.rotation;
                    instance.Instance.transform.localScale = new Vector3(instance.Scale, instance.Scale, instance.Scale);
                    if (instance.GrabbableInMenu)
                    {
                        instance.ExpandedBounds = GrabbableBehavior.CalculateExpandedBounds(instance.Instance);
                    }
                    StageDressing.Logger.Info($"Rebuild Menu Instances - New Instance {instance.Instance.name}");
                });
            });
        }
Пример #2
0
        /// <summary>
        /// Instantiate only the visible and enabled instances for the Game Scene
        /// </summary>
        public void CreateGameInstances()
        {
            this.DestroyAllInstances();

            // Get all enabled menu game objects
            IEnumerable <PrefabData> enabledGamePrefabs = this.Configuration.Scenes.Where(s => s.ShowInGame).SelectMany(s => s.Prefabs).Where(go => go.Enabled);

            enabledGamePrefabs.ToList().ForEach(p =>
            {
                p.Instances.ForEach(instance =>
                {
                    instance.Instance       = GameObject.Instantiate(p.Prefab);
                    instance.Instance.name += "_GameInstance";
                    instance.Instance.transform.position   = instance.Pose.position;
                    instance.Instance.transform.rotation   = instance.Pose.rotation;
                    instance.Instance.transform.localScale = new Vector3(instance.Scale, instance.Scale, instance.Scale);
                    if (instance.GrabbableInGame)
                    {
                        instance.ExpandedBounds = GrabbableBehavior.CalculateExpandedBounds(instance.Instance);
                    }
                    StageDressing.Logger.Info($"Create Game Instances - New Instance {instance.Instance.name}");
                });
            });
        }