private async Task <GameObject> CreateDisplayalFromExhibit(Exhibit e)
        {
            await Task.Yield();

            var displayalPrefab = ObjectFactory.GetDisplayalPrefab();

            var displayal = Instantiate(displayalPrefab, Anchor.transform, true);

            var pos = new Vector3(e.Position.X, e.Position.Y, -ExhibitionBuildingSettings.Instance.WallOffset);

            displayal.transform.localPosition = pos;

            // Non-90° as they would tip over otherwise (exhibits stand on the little bar below).
            var rot = VrepController.Instance.settings.PlaygroundEnabled
        ? Quaternion.Euler(91.0f, 0, 180) // Slightly more than 90° or it would fall down.
        : Quaternion.Euler(90, 0, 180);

            displayal.transform.localRotation = rot; // Required due to prefab orientation.

            if (!VrepController.Instance.settings.SpotsEnabled || !e.Light)
            {
                displayal.transform.Find("Directional light").gameObject.SetActive(false);
            }

            var image = displayal.transform.Find("Plane").gameObject.AddComponent <ImageLoader>();

            image.ReloadImage(e.Path);
            displayal.transform.localScale = ScalingUtility.ConvertMeters2PlaneScaleSize(e.Size.X, e.Size.Y);

            if (e.Audio != null)
            {
                var closenessDetector = displayal.AddComponent <ClosenessDetector>();
                closenessDetector.url = e.Audio;
            }

            Displayal displayalComponent = displayal.gameObject.GetComponent <Displayal>();

            displayalComponent.SetExhibitModel(e);
            displayalComponent.originalPosition = pos;
            displayalComponent.originalRotation = rot;

            displayals.Add(displayalComponent);

            return(displayal);
        }
Esempio n. 2
0
        public void AttachExhibits()
        {
            // TODO Make displayal configurable
            var prefab = ObjectFactory.GetDisplayalPrefab();

            foreach (var e in WallData.exhibits)
            {
                GameObject displayal = Instantiate(prefab);
                displayal.name             = "Displayal (" + e.name + ")";
                displayal.transform.parent = Anchor.transform;
                var pos = new Vector3(e.position.x, e.position.y, -ExhibitionBuildingSettings.Instance.WallOffset);
                displayal.transform.localPosition = pos;
                //displayal.transform.rotation = Quaternion.Euler(ObjectFactory.CalculateRotation(WallData.direction));
                var rot = Quaternion.Euler(92.5f, 0, 180); // Non-90° as they would tip over othervise
                displayal.transform.localRotation = rot;   // Because prefab is messed up


                if (!VREPController.Instance.Settings.SpotsEnabled || !e.light)
                {
                    displayal.transform.Find("Directional light").gameObject.SetActive(false);
                }

                Displayal disp = displayal.gameObject.GetComponent <Displayal>();
                disp.SetExhibitModel(e);
                disp.OriginalPosition = pos;
                disp.OriginalRotation = rot;
                Displayals.Add(disp);

                ImageLoader image = displayal.transform.Find("Plane").gameObject.AddComponent <ImageLoader>(); // Displayal
                //ImageLoader image = displayal.AddComponent<ImageLoader>();// ImageDisplayPlane
                image.ReloadImage(e.GetURLEncodedPath());
                displayal.transform.localScale = ScalingUtility.convertMeters2PlaneScaleSize(e.size.x, e.size.y);

                if (e.audio != null)
                {
                    Debug.Log("added audio to display object");
                    var closenessDetector = displayal.AddComponent <ClosenessDetector>();
                    closenessDetector.url = e.GetURLEncodedAudioPath();
                }
            }
        }