예제 #1
0
        private void InitializePortalsForChannel(int channel)
        {
            List <OldPortalSettings> settings = receiversByChannel[channel].ToList();

            // Create a container game object which contains all the elements of the portal
            List <OldPortalContainer> portalContainers = CreatePortalContainers(channel);

            // Create a Portal Camera which renders to a RenderTexture for each Receiver in the channel
            List <OldPortalCameraFollow> portalCameras = CreatePortalCameras(channel);

            // Create the Portal Teleporters on each PortalSettings
            List <OldPortalTeleporter> portalTeleporters = CreatePortalTeleporters(channel);

            // Create the volumetric portal gameobjects
            List <GameObject> volumetricPortalObjects = CreateVolumetricPortalObjects(channel);

            // Create the trigger zones for volumetric portals
            List <OldVolumetricPortalTrigger> volumetricPortalTriggers = CreateVolumetricPortalTriggers(channel);

            // Initialize all references needed
            for (int i = 0; i < portalContainers.Count; i++)
            {
                int other = (i + 1) % 2;

                OldPortalContainer         portalContainer           = portalContainers[i];
                OldPortalSettings          portalSettings            = settings[i];
                Portal                     portalCameraRenderTexture = portalSettings.gameObject.AddComponent <Portal>();
                OldPortalCameraFollow      portalCameraFollow        = portalCameras[i];
                OldPortalTeleporter        portalTeleporter          = portalTeleporters[i];
                GameObject                 volumetricPortalObject    = volumetricPortalObjects[i];
                OldVolumetricPortalTrigger volumetricPortalTrigger   = volumetricPortalTriggers[i];

                // PortalContainer references
                portalContainer.otherPortal             = portalContainers[other];
                portalContainer.portalCamera            = portalCameraFollow.GetComponent <Camera>();
                portalContainer.settings                = portalSettings;
                portalContainer.teleporter              = portalTeleporters[i];
                portalContainer.volumetricPortal        = volumetricPortalObject;
                portalContainer.volumetricPortalTrigger = volumetricPortalTrigger;

                // PortalCameraRenderTexture references
                portalCameraRenderTexture.portal = portalContainer;

                // PortalCameraFollow references
                portalCameraFollow.portalBeingRendered = portalContainer;

                // PortalTeleporter references
                portalTeleporter.portal = portalContainer;

                // VolumetricPortalTrigger references
                volumetricPortalTrigger.portal = portalContainer;

                if (Vector3.Dot(portalTeleporter.portalNormal, portalTeleporter.transform.forward) > 0)
                {
                    volumetricPortalObject.transform.localRotation = Quaternion.Euler(0, 180, 0);
                }
            }
        }
예제 #2
0
        private OldPortalContainer CreatePortalContainer(OldPortalSettings receiver)
        {
            GameObject portalContainer = new GameObject(receiver.gameObject.name + " Container");

            portalContainer.transform.SetParent(receiver.transform.parent);
            portalContainer.transform.localPosition = receiver.transform.localPosition;

            receiver.transform.SetParent(portalContainer.transform);

            OldPortalContainer containerScript = portalContainer.AddComponent <OldPortalContainer>();

            return(containerScript);
        }