Light灯光组件+组件的相关操作+游戏资源的加载

Light灯光组件

Type: Directional:平行光,模仿的是太阳光

Spot:聚光灯

Area:区域光

Color: 颜色值

Mode: RealTime:实时

Mix:混合

Baked:烘焙

Intersity: 光照强度

Indirect Multiplier:光照强度乘数

Shadow Type:影子设置: No Shadow 没有影子 Hard Shadow:硬影子 soft Shadow:柔和影子

cookie: (类似于)灯光上贴的一层纸 size;

Draw halo:辉光(个人认为类似于朦胧的月光感)

Culling Mask:裁剪层

组件的获取,添加,删除等操作

相关代码如下:

cs 复制代码
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A)){
            light1.type = LightType.Spot;
            light1.range = 20;
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            light1.type = LightType.Point;
            //组件的获取
            TestComponent tc = lightObj.GetComponent<TestComponent>();
            if (tc)
            {
                light1.range = tc.range;
            }
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            //组件的添加
            TestComponent tc = lightObj.AddComponent<TestComponent>();
            tc.age = 100;
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            //组件的销毁
            TestComponent tc2 = lightObj.GetComponent<TestComponent>();
            Destroy(tc2);
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            //组件的失活
            TestComponent tc3 = lightObj.GetComponent<TestComponent>();
            tc3.enabled = false;
        }
        if(Input.GetKeyDown(KeyCode.F)){
            //组件的激活
            TestComponent tc3 = lightObj.GetComponent<TestComponent>();
            tc3.enabled = true;
    }
游戏资源的加载

代码如下:

cs 复制代码
         if (Input.GetKeyDown(KeyCode.G))
        {
            //Project面板中Resources文件不能错任何字母和大小写
            //加载Resources文件夹中的资源,泛型加载
            GameObject go = Resources.Load<GameObject>("Prefab/Tank");
            //实例化游戏资源
            Instantiate(go);
            //方法2
            GameObject go1 = Resources.Load("Prefab/Tank") as GameObject;
            Instantiate(go1);
        }

运行结果如下,按G键clone出一个Tank预制体。

该系列专栏为网课课程笔记,仅用于学习参考。

相关推荐
sindyra1 小时前
Unity UGUI 之 Canvas Scaler
unity·游戏引擎
c#上位机2 小时前
halcon计算区域骨架
图像处理·人工智能·计算机视觉·c#·halcon
曹牧3 小时前
C#:Dictionary类型数组
java·开发语言·c#
GeekyGuru4 小时前
C#:游戏开发的高效利器
开发语言·c#
关关长语4 小时前
基于NCrontab实现Covarel扩展秒级任务调度
c#·.net
在路上看风景5 小时前
2.Square Grid
unity
足球中国5 小时前
什么情况下会发生跨域
c#·dataexcel·cfucion
程序猿阿伟5 小时前
《突破Unity热更新瓶颈:底层函数调用限制与生态适配秘籍》
unity·游戏引擎
yue0086 小时前
C# 实现电脑锁屏功能
开发语言·c#·电脑·电脑锁屏
2501_930707786 小时前
如何在 C# 中分离饼图的某个区域
开发语言·c#