Example #1
0
        void InitPortal()
        {
            GameObject go = Instantiate(PortalPrefab);

            go.transform.position = ViveSR_Experience.instance.PlayerHeadCollision.transform.position + ViveSR_Experience.instance.PlayerHeadCollision.transform.forward * 0.5f;
            go.transform.forward  = -ViveSR_Experience.instance.PlayerHeadCollision.transform.forward;
            PortalManager.AddPortal(go);
            Portal = go.GetComponent <ViveSR_Portal>();

            OldPosition = Portal.transform.position;

            StartCoroutine(CheckViewerInWorld());
            StartCoroutine(CheckPortalPosition());
        }
        IEnumerator GenerateNPCs()
        {
            portalMgr.ClearAllPortals();
            isGeneratingNPC = true;

            ViveSR_Portal portal = Instantiate(PortalPrefeb.GetComponent <ViveSR_Portal>());

            portal.TransitionMaterialUpdateCB = TransitionMatCB;

            portal.transform.position = Portal_Pos;
            portal.transform.forward  = -Spawn_Fwd;

            portalMgr.AddPortal(portal.gameObject);
            portalMgr.UpdateViewerWorld();

            ViveSR_Experience_PortalAnimation pa = portal.GetComponent <ViveSR_Experience_PortalAnimation>();

            pa.PortalLogo.gameObject.layer = LayerMask.NameToLayer("VirtualWorldLayer");

            while (NPCRefs.Count < NumOfNPC && isGeneratingNPC)
            {
                ViveSR_Experience_NPCAnimationRef NPCRef = Instantiate(NPCPrefab).GetComponent <ViveSR_Experience_NPCAnimationRef>();
                NPCRefs.Add(NPCRef);

                NPCRef.transform.position = Spawn_Pos;
                NPCRef.transform.forward  = -Spawn_Fwd;

                NPCRef.NPCAnimController.Walk(Portal_Pos, () =>
                {
                    AssignClosestChair(NPCRef);
                });

                //next fairy
                yield return(new WaitForSeconds(2f));
            }

            if (pa != null)
            {
                pa.SetPortalScale(false);
            }

            isGeneratingNPC = false;
        }