コード例 #1
0
    public static SmoothLightingManager Create()
    {
        var go = new GameObject("SmoothLightingManager");

        go.transform.position = new Vector3(0, 2, 0);
        var slm = go.AddComponent <SmoothLightingManager>();

        slm.mf = SimpleQuad.ImmediateAdd(go, 10, 10);

        slm.rt = new RenderTexture(Screen.width, Screen.height, 24);

        slm.slc = SmoothLightCamera.Create(slm.rt);
        //slm.slc.GetComponent<Camera>().targetTexture = slm.rt;

        var renderer = go.GetComponent <MeshRenderer>();

        //renderer.material.shader = Shader.Find("Unlit/Transparent");
        renderer.material.shader      = Resources.Load <Shader>("shaders/ShadowShader");
        renderer.material.mainTexture = slm.rt;

        slm.lightTex = Resources.Load <Texture2D>("sprites/light-mask");
        slm.blackTex = createBlackTex();

        return(slm);
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        probe = gameObject.AddComponent <SmoothLightProbe>();

        mf = SimpleQuad.ImmediateAdd(gameObject, 0.5f, 0.5f);

        onTex  = Texture2D.whiteTexture;
        offTex = Texture2D.blackTexture;
    }
コード例 #3
0
ファイル: Ground.cs プロジェクト: atamis/planet6
    public static Ground Create()
    {
        var go     = new GameObject("Ground");
        var ground = go.AddComponent <Ground>();


        SimpleQuad.ImmediateAdd(go, 20, 20);

        // MeshCollider has trouble with local scale changes, even when added after the scale changes.
        go.AddComponent <MeshCollider>();

        ground.nms = go.AddComponent <NavMeshSurface>();

        ground.nms.BuildNavMesh();

        return(ground);
    }
コード例 #4
0
    public void Update()
    {
        if (radius != lastRadius)
        {
            SimpleQuad.ImmediateAdd(lightModel, radius * 2, radius * 2);
            lastRadius = radius;
            var mr = lightModel.GetComponent <MeshRenderer>();
            mr.material = new Material(Shader.Find("Custom/Circle2"));

            var mf = lightModel.GetComponent <MeshFilter>();
            var mc = lightModel.GetComponent <SphereCollider>();
            mc.radius = radius / 2; // TODO: Because lighthalo's "radius" is actually a diameter (see powerbroadcaster);
            //mc.sharedMesh = mf.sharedMesh;
            // TODO: this causes a "cleaning the mesh failed" error
            // sometimes. This is related to 0 size meshes (like when
            // the lighthalo radius is 0), but a fix is not immediately
            // apparent.
        }
    }
コード例 #5
0
ファイル: PowerBroadcaster.cs プロジェクト: atamis/planet6
    public void Update()
    {
        var powerable = GetComponent <Powerable>();

        if (powerable.powered)
        {
            radius = 3; // TODO: radius is always 3
            Collider[] hits = Physics.OverlapSphere(powerField.transform.position, radius, 1 << 9);

            foreach (Collider hit in hits)
            {
                // Get in parent because the collider is on the model
                var hitPowerable = hit.GetComponentInParent <Powerable>();
                if (hitPowerable)
                {
                    hitPowerable.powered = true;
                }
            }
        }
        else
        {
            // "Disable" the field if we aren't powered
            radius = 0;
        }

        if (radius != lastRadius)
        {
            // TODO: instead of remaking quad, maybe resize?

            // radius * 2 because the size is for 1 side of the quad, which
            // will be the diameter of the circle;
            SimpleQuad.ImmediateAdd(powerField, radius * 2, radius * 2);
            lastRadius = radius;
            var mr = powerField.GetComponent <MeshRenderer>();
            mr.material = new Material(Shader.Find("Custom/Circle2"));
            mr.material.SetColor("_Color", new Color(0.0f, 0.0f, 1, 0.2f));
        }
    }