Exemple #1
0
        private async Task <GameObject> CreatePlayersPlaceAsync()
        {
            (Vector3[] vertices, int[] triangles) = await Task.Run(() => ParseMesh("CustomFloorPlugin.Assets.PlayersPlace.mesh"));

            Mesh mesh = new()
            {
                vertices  = vertices,
                triangles = triangles
            };

            GameObject playersPlaceCube = GameObject.CreatePrimitive(PrimitiveType.Cube);

            playersPlaceCube.SetActive(false);
            MeshRenderer cubeRenderer = playersPlaceCube.GetComponent <MeshRenderer>();

            (Material darkEnvSimpleMaterial, _, _) = await _materialSwapper.MaterialsTask;
            cubeRenderer.material = darkEnvSimpleMaterial;
            playersPlaceCube.transform.localPosition = new Vector3(0f, -50.0075f, 0f);
            playersPlaceCube.transform.localScale    = new Vector3(3f, 100f, 2f);
            playersPlaceCube.name = "PlayersPlace";

            GameObject playersPlaceMirror = GameObject.CreatePrimitive(PrimitiveType.Plane);

            playersPlaceMirror.name = "Mirror";
            playersPlaceMirror.transform.SetParent(playersPlaceCube.transform);
            playersPlaceMirror.transform.localScale    = new Vector3(0.1f, 0f, 0.1f);
            playersPlaceMirror.transform.localPosition = new Vector3(0f, 0.5001f, 0f);
            TrackMirror trackMirror = playersPlaceMirror.AddComponent <TrackMirror>();

            trackMirror.bumpIntensity = 0.02f;
            using Stream floorStream  = GetEmbeddedResource("CustomFloorPlugin.Assets.Floor.png");
            trackMirror.normalTexture = floorStream.ReadTexture2D();
            trackMirror.PlatformEnabled(_container);

            GameObject playersPlaceFrame = new("Frame");

            playersPlaceFrame.transform.SetParent(playersPlaceCube.transform);
            playersPlaceFrame.AddComponent <MeshRenderer>();
            MeshFilter meshFilter = playersPlaceFrame.AddComponent <MeshFilter>();

            meshFilter.mesh = mesh;
            TubeLight tubeLight = playersPlaceFrame.AddComponent <TubeLight>();

            tubeLight.color = Color.blue;
            tubeLight.PlatformEnabled(_container);

            return(playersPlaceCube);
        }
        private GameObject CreatePlayersPlace()
        {
            GameObject playersPlaceCube = GameObject.CreatePrimitive(PrimitiveType.Cube);

            playersPlaceCube.SetActive(false);
            Transform playersPlaceCubeTransform = playersPlaceCube.transform;

            playersPlaceCubeTransform.SetParent(_anchor);
            MeshRenderer cubeRenderer = playersPlaceCube.GetComponent <MeshRenderer>();

            cubeRenderer.material = _materialSwapper.DarkEnvSimpleMaterial;
            playersPlaceCubeTransform.localPosition = new Vector3(0f, -50.0075f, 0f);
            playersPlaceCubeTransform.localScale    = new Vector3(3f, 100f, 2f);
            playersPlaceCube.name = "PlayersPlace";

            GameObject playersPlaceMirror          = GameObject.CreatePrimitive(PrimitiveType.Plane);
            Transform  playersPlaceMirrorTransform = playersPlaceMirror.transform;

            playersPlaceMirror.name = "Mirror";
            playersPlaceMirrorTransform.SetParent(playersPlaceCubeTransform);
            playersPlaceMirrorTransform.localScale    = new Vector3(0.1f, 0f, 0.1f);
            playersPlaceMirrorTransform.localPosition = new Vector3(0f, 0.5001f, 0f);
            TrackMirror trackMirror = playersPlaceMirror.AddComponent <TrackMirror>();

            trackMirror.bumpIntensity = 0.02f;
            using Stream floorStream  = GetEmbeddedResource("CustomFloorPlugin.Assets.Floor.png");
            trackMirror.normalTexture = floorStream.ReadTexture2D();
            trackMirror.PlatformEnabled(_container);

            GameObject playersPlaceFrame = new("Frame");

            playersPlaceFrame.transform.SetParent(playersPlaceCubeTransform);
            playersPlaceFrame.AddComponent <MeshRenderer>();
            MeshFilter meshFilter = playersPlaceFrame.AddComponent <MeshFilter>();

            meshFilter.mesh = ParseMesh("CustomFloorPlugin.Assets.PlayersPlace.mesh");
            TubeLight tubeLight = playersPlaceFrame.AddComponent <TubeLight>();

            tubeLight.color = Color.blue;
            tubeLight.PlatformEnabled(_container);

            return(playersPlaceCube);
        }