Beispiel #1
0
        void SetupGameObject()
        {
            singularityGO      = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            singularityGO.name = name + " singularity";

            singularityGO.layer = 10;

            singularityGO.transform.position = gameObject.transform.position;
            singularityGO.transform.parent   = gameObject.transform;

            GameObject.Destroy(singularityGO.GetComponent <Collider> ());

            singularityGO.transform.localScale = new Vector3(enclosingMeshRadius / gameObject.transform.localScale.x, enclosingMeshRadius / gameObject.transform.localScale.y, enclosingMeshRadius / gameObject.transform.localScale.z);

            MeshRenderer singularityMR = singularityGO.GetComponent <MeshRenderer> ();

            singularityMR.material          = singularityMaterial;
            singularityMR.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            singularityMR.receiveShadows    = false;
            singularityMR.enabled           = true;

            singularityCubeMap = singularityGO.AddComponent <SingularityCenteredCubeMap> ();
            singularityCubeMap.singularityMaterial = singularityMaterial;
            singularityCubeMap.parentSingularity   = this;
        }
Beispiel #2
0
        IEnumerator SetupWormhole()
        {
            yield return(new WaitForFixedUpdate());

            singularityMaterial.DisableKeyword("WORMHOLE_ON");
            singularityMaterial.EnableKeyword("WORMHOLE_OFF");
            hasWormhole = false;

            if (!String.IsNullOrEmpty(wormholeTarget))
            {
                SingularityObject wormholeTargetSingularity = Singularity.Instance.loadedObjects.SingleOrDefault(_so => _so.name == wormholeTarget);

                if (ReferenceEquals(wormholeTargetSingularity, null))
                {
                    Utils.LogError("Wormhole target not found, disabling");
                    yield break;
                }
                singularityMaterial.SetTexture("wormholeCubemap", wormholeTargetSingularity.singularityCubeMap.singularityCubemap);
                singularityMaterial.DisableKeyword("WORMHOLE_OFF");
                singularityMaterial.EnableKeyword("WORMHOLE_ON");
                wormholeCubeMap = wormholeTargetSingularity.singularityCubeMap;
                hasWormhole     = true;
            }
        }