Compare commits

..

47 Commits

Author SHA1 Message Date
6069009e4e 合并分支 2021-12-28 20:12:00 +08:00
bf213bea54 优化游戏特效及制作游戏音效
优化:
1.基督小怪的shader添加完毕,但是小怪的闪电似乎有bug,见末尾bug集合
2.给炸弹爆炸加入了粒子特效
3.优化了死亡的屏幕后特效,现在做到了只有黑白区域才会渲染死亡鬼魂的效果

音效:
1.制作了地藏的全部音效
2.制作了特洛伊木马的全部音效
3.制作了以撒的全部音效
4.制作了玩家 跳跃,挥锤子,扔镰刀,受击,死亡,与击中敌人的音效,目前还缺少交互音效
5.制作了爱欲品的抱人音效
6.制作了所有与爆炸相关的音效

音效大体上已经制作完毕,逻辑也已经写完了
如果有不合适的音效改起来还算容易

问题:
1.目前在交互时(对话,看牌子),玩家可以进行挥砍和跳跃
2.基督石像的雷击效果只有一半不知道是不是bug
3.基督石像我没有找到他的受击函数,所以他的受击音效我没有制作

下班,绷不住了,真就干了后半夜。
2021-12-28 05:01:18 +08:00
0d7446d2e7 修改建议及完善特效
修改建议:
1.添加了击中的粒子特效,但是还需要迭代
2.修复马死后灰尘不会消失的bug

完善特效
1.制作了死亡时的阴间特效,已经在全场景实装
2.制作了闪电的辉光特效。
3.调整了所有场景的全局shader以适配死亡阴间特效
2021-12-25 22:53:32 +08:00
Roman
9f3ffbb94c 任务:编写留言系统、死亡记录系统、替换和实装美术素材
1.编写死亡记录系统
(1.当触发玩家死亡事件,传送一条记录前往服务器
(2.当触发玩家死亡事件,拉取云端死亡列表,挑选10条显示在场景
*.制作死亡玩家预制体

3.制作玩家UI

4.制作boss血条

*.替换和实装美术素材,增加部分动画

*优化和修复
1.调整了留言板的建立偏移,修复了留言板浮空的问题
2.修复了建板系统的操控性问题
3.解决了落在留言板上会导致动画异常的问题

建议:
1.给击中添加一些效果,目前还是打击感太弱
2.目前木马死后,灰尘不会消失

*.至此,死亡标记系统基本完成

下班
2021-12-25 18:27:29 +08:00
Roman
ca1cc0162d 任务:编写留言系统、替换和实装美术素材
1.编写留言系统
(1.当玩家无Catch的时候,记录长按Y的时间,若时间大于两秒,呼唤UI,触发相应事件

*.编写撰写留言板逻辑
(*.清空操作地图
(1.呼出留言板UI
(2.当按下确认键,确认建立一个本地留言板,并初始化该本地留言板,恢复操作地图
(3.将留言板数据传向云端

*.编写留言板逻辑
(1.内含BoardInfo内的信息
(2.继承于可交互物体
(3.当交互,呼出留言板UI,显示内容、UID等信息
(4.当按下返回键,关闭UI

*.编写拉取留言板系统
(1.加在开幕演出中,开幕时呼叫sql上的脚本,拉取若干条留言板
(2.在场景内创建留言板,并初始化信息

*.替换和实装美术素材,增加部分动画
1.增加村内上树动画
2.更新村场景,使得玩家可以走到村下
3.制作以撒闪电攻击动画
4.制作以撒冲撞攻击动画
5.制作以撒雕像碎裂动画
6.贴上对话框
7.制作以撒闪电攻击动画
8.制作村民和贵族的待机角色
9.制作特洛伊木马死亡动画
10.制作特洛伊木马的喷射动画

*优化和修复
1.修复佛教前置关掉怪陷阱有时不会触发的问题
2.重做渲染层,避免出现覆盖问题
3.修复玩家会卡在村里桥上的问题
4.解决了屎山代码的warming问题
5.删除了子弹时间,效果太差

建议:
1.给击中添加一些效果,目前还是打击感太弱
2.目前木马死后,灰尘不会消失

*.至此,留言系统全部完成

下班
2021-12-25 00:37:29 +08:00
Roman
0bbb5810ec Squashed commit of the following:
commit 274a0206955902d3fa12cdddcbed9a93fac556c4
Author: SAIPO <grasste0403@hotmail.com>
Date:   Thu Dec 23 22:24:34 2021 +0800

    修改建议及完善特效

    修改建议:
    1.给所有关卡加入了全局shader,但不同区域的shader效果会有区别
    2.给地藏敲钟的灰尘加入了渐隐
    3.给木马吐出的普通炸弹加入了拖尾(不清楚是否建议召唤的炸弹也加入拖尾,但最好只给吐出的炸弹加,这样可以区别是否可以弹反)
    4.修改了以撒发怒时场景全局shader的变化速度
    5.给以撒的鬼魂粒子加入了淡入淡出

    增加:
    1.为地藏的手加入了粒子特效,现在手移动时会掉落粒子
    2.为弹反的检测圆圈加入了发光光环的效果

    bug:
    目前在以撒boss关卡中执行开场事件前玩家可以移动,会导致闪现

commit f54cf4f2a30a4732be13947d2b8e85ca55f5137f
Author: SAIPO <grasste0403@hotmail.com>
Date:   Thu Dec 23 18:43:52 2021 +0800

    合并分支

commit bb3be793ca5db3df43679f2d6c34c75f768047a1
Author: SAIPO <grasste0403@hotmail.com>
Date:   Wed Dec 22 07:46:07 2021 +0800

    修改佛教Boss关卡和伊斯兰Boss关卡的粒子特效

commit 1987a63954402be8894f9cc9805545432afefa18
Author: SAIPO <grasste0403@hotmail.com>
Date:   Tue Dec 21 20:55:05 2021 +0800

    任务:编写shader,完善数据库类
    1.完善了PlayerInfo类,用以数据库功能
     1) 编写GetSqlData()函数,使用多线程获取用户信息,使用前请先设置公关变量name。
     2) 编写CreateUser(string username)函数,在用户表内创建一个用户。
     3) 编写hasName(string _searchName)函数,判断是否存在这个用户。
     4) 编写GetBoardInfo(int WorldId)函数,获取指定世界的留言板链表。
     5) 编写GetDeadInfo(int WorldId)函数,获取指定世界的死亡信息链表。
     6) 编写CreateDead(int WorldId, Vector2 postion)函数,创建一条死亡信息。
     7) 编写CreateBoard(int WorldId, Vector2 postion,string text)函数,创建一条留言信息。
     8) 编写UpdatePlayerInfo()函数,将类里储存的信息上传到数据库。

    2.实装相关Shader
     1)完善以撒关卡的屏幕后特效,使其可以在发怒场景发出红色辉光。
     2)完善以撒鬼魂的粒子,并且颜色和发怒与否关联。
     3)实装以撒关卡的窗户辉光效果。
     4)实装伊斯兰Boss关卡炸弹弹反的粒子特效。
     5)实装伊斯兰Boss关卡的尘土特效(需要重做)
     6)实装佛教Boss关卡的敲钟声波特效。
     7)实装佛教Boss关卡的钟声受击灰尘(需要重做)

    3.目前发现的bug
     1)当人物恰好调到角落里会卡动画。
     2)伊斯兰Boss关卡,特洛伊木马吐出的炸弹落到特效小怪上会闪退。

commit c06b842382051bc260d9f509491c683a41ca2a4c
Author: SAIPO <grasste0403@hotmail.com>
Date:   Tue Dec 21 14:08:06 2021 +0800

    Squashed commit of the following:

    commit e7dcdec1d9913e283f42d42f72f1030f0c8b6fda
    Author: Roman <1325980292@qq.com>
    Date:   Tue Dec 21 00:45:50 2021 +0800

        任务:搭建前置关卡,编写演出逻辑

        1.流程化游戏
        (1.制作转移器,内含字典,根据玩家的静态属性“阶段”来决定到转移点后将会移动到哪一个场景
        (2.制作转场器,水平方向从左到右

        下班

    commit 74f926815ec8d00fa051192eb3b978ff4b3c01a6
    Author: Roman <1325980292@qq.com>
    Date:   Mon Dec 20 23:33:14 2021 +0800

        任务:搭建前置关卡,编写演出逻辑

        1.编写基督前置关卡
        (1.放置平台、怪物和男童
        (2.修改男童类,外加OnSaveEvent,OnSave时若有事件则触发该Event
        (3.编写开幕演出,与yi前置类似
        (4.编写男童解救演出
        ((1.触发Fungus对话
        ((2.对话结束后,开启通往上层的门

        2.搭建村场景
        (1.放置平台和元素
        (2.为可动元素制作动画

        3.为玩家添加static属性,进度。0:刚开,1进村,2通佛,3通伊,4.通基

        4.制作死亡重开功能
        (1.当玩家生命值降到0及以下,触发死亡事件
        (2.死亡后reload当前场景,并设记录员,关闭某些事件和演出不再执行

        *优化和修复
        (1.尝试制作击中卡肉效果,目前打击感太弱。也可以尝试粒子效果

        *至此,全部前置关卡搭建完毕,村场景搭建完毕。
        *明天可以完成流程化,接下来就是填充剧情、UI、死亡标记和留言板等系统了

        下班

    commit f257b40d10373a13380e9c395fe94d6559a82a0f
    Author: Roman <1325980292@qq.com>
    Date:   Sun Dec 19 23:57:44 2021 +0800

        任务:搭建前置关卡,编写演出逻辑

        1.编写佛教前置关开场演出
        (*.休整地形,使得左边多出一块地面,方便演出正常运作
        (*.项目后期再通过逻辑触发该演出,目前先用调试方式触发演出
        (1.关闭空气墙
        (2.修改玩家inputDir使玩家从屏幕外冲进到屏幕内部
        (3.等待一段时间
        (4.此时玩家应该走到某个合适的位置,停止玩家的inputDir
        (5.等待一小段时间给玩家反应
        (6.修改相机offset,使其对准对话的两个小怪
        (7.等待一小段时间给玩家反应
        (8.触发Fungus对话
        (9.Fungus对话结束后,返回标记命令演出Main继续执行
        *.修改NormalEnemy,添加标识isInFoStage,在Update中判断,若是,使该怪物水平方向上追踪玩家,可以参考爱欲品的Seek
        (10.修改左边小怪的isInFoStage
        (11.开启右边小怪的Path动画,表现其慌忙逃跑
        (12.Invoke一个延时,等右边小怪逃出视野后删除它
        (13.触发善后和结束事件
        (14.重写善后事件,重新开启空气墙

        2.搭建伊斯兰前置关卡

        3.创建伊斯兰前置关卡演出
        (1.关闭空气墙
        (2.修改玩家inputDir使玩家从屏幕外冲进到屏幕内部
        (3.等待一段时间
        (4.此时玩家应该走到某个合适的位置,停止玩家的inputDir
        (5.等待一小段时间给玩家反应
        (6.触发善后与结束事件

        4.创建玩家隔间触发事件
        (1.是进入式触发器对象
        (2.触发时Call隔间演出

        5.编写隔间演出逻辑
        (1.表现关门
        (2.左右晃一下镜头,中心移动到左右门处,表示门被关闭
        (3.镜头回到玩家处,同时压缩相机可移动范围更窄
        (4.打开隔间墙壁的空气墙
        (5.设置EndEvent为伊斯兰事件

        6.编写召唤伊斯兰事件
        (1.摘自木马的召唤攻击,稍作修改
        (2.当召唤的伊斯兰全部挂了,触发隔间结束事件

        7.编写隔间结束事件
        (1.表现开门
        (2.关闭隔间的空气墙
        (3.重设相机移动范围

        8.搭建基督前置关卡

        *.至此,第一关、第二关前置关卡的逻辑基本开发完毕

        *.明天能做完所有前置关,顺便应该能搭完村场景,后天可以开始搭建新系统,目前还差留言、死亡标记等系统等待编写

        下班

    commit cd22966ad7637a84c0f08c3a716d5ec549699749
    Author: Roman <1325980292@qq.com>
    Date:   Sun Dec 19 14:12:05 2021 +0800

        Squashed commit of the following:

        commit 26aff356971bdc2c2a6a3bd444eeb50c4bf7ec14
        Author: SAIPO <grasste0403@hotmail.com>
        Date:   Sun Dec 19 02:20:44 2021 +0800

            导入近期制作的一些Shader
            1.合并分支
            2.完成了人物描边的流动shader制作,并且可以对Bloom屏幕后处理产生反应。
            3.完成了基督教boss关卡,彩色窗户辉光的shader制作,可以对Bloom产生反应。
            4.完成了伊斯兰教弹反的炸弹拖尾粒子shader的制作。
            5.完成了火焰粒子shader的制作(可以用在基督教的以撒鬼魂上)。
            6.完成了灰尘粒子像素化的shader制作。
            7.完成了边缘扭曲的shader制作,可以用在一些树木上,让画面产生动感。

            明天制作敲钟的声波Shader

    # Conflicts:
    #	UserSettings/EditorUserSettings.asset

commit 26aff356971bdc2c2a6a3bd444eeb50c4bf7ec14
Author: SAIPO <grasste0403@hotmail.com>
Date:   Sun Dec 19 02:20:44 2021 +0800

    导入近期制作的一些Shader
    1.合并分支
    2.完成了人物描边的流动shader制作,并且可以对Bloom屏幕后处理产生反应。
    3.完成了基督教boss关卡,彩色窗户辉光的shader制作,可以对Bloom产生反应。
    4.完成了伊斯兰教弹反的炸弹拖尾粒子shader的制作。
    5.完成了火焰粒子shader的制作(可以用在基督教的以撒鬼魂上)。
    6.完成了灰尘粒子像素化的shader制作。
    7.完成了边缘扭曲的shader制作,可以用在一些树木上,让画面产生动感。

    明天制作敲钟的声波Shader

# Conflicts:
#	Assets/Prefabs/以撒鬼魂.prefab
#	Assets/Scenes/DiZangStageTest.unity
#	Assets/Scenes/Fo.unity
#	Assets/Scenes/Ji.unity
#	Assets/Scenes/Postprocessing/伊斯兰教boss.asset
#	Assets/Scenes/Postprocessing/佛教boss.asset
#	Assets/Scenes/Postprocessing/基督教boss.asset
#	Assets/Scenes/TeLuoYiStageTest.unity
#	Assets/Scenes/Yi.unity
#	Assets/Scenes/YiSaStageTest.unity
#	Assets/Scenes/cun.unity
#	Assets/Scripts/Boss/以撒/YiSa.cs
#	Assets/Scripts/Boss/地藏/Bell.cs
#	Assets/Scripts/Boss/地藏/DiZang.cs
#	Assets/Scripts/Boss/木马/Boomer.cs
#	Assets/Scripts/演出/伊斯兰前置关/RoomEndStage.cs
#	Assets/Scripts/演出/伊斯兰前置关/RoomStartStage.cs
#	Assets/Shader/人物描边/Stroke.shadergraph
#	Assets/Shader/灰尘粒子用shader/佛教关卡专用 1.mat
#	Logs/ApiUpdaterCheck.txt
#	UserSettings/EditorUserSettings.asset
2021-12-24 02:07:24 +08:00
Roman
19a870409a 任务:流程化游戏
1.实装数据库系统
(1.制作简易opening场景
(2.放置输入框
(3.放置确认按钮
(4.当输入框开启时,若检测到按下某键,触发检查
(5.若检查结果为有该用户,拉取用户信息
(6.若没有,创建一个用户再拉取用户信息
(7.完成善后工作,转移到场景“cun”

*.制作和替换美术素材,增加部分动画

*优化和修复
1.修复佛教前置关掉怪陷阱下落太慢的问题

建议:
1.给普通关卡和村也加上类似Boos的全局shader,目前从关卡间过度的时候能够看出明显的区别
2.建议给地藏敲钟攻击的灰尘加上渐隐,目前是瞬间消失的,十分违和
3.建议给普通的炸弹也加上拖尾,很酷
4.以撒发怒时变红太快了,消散得也太快了
5.以撒鬼魂的粒子也建议加上淡入和淡出

*.

下班
2021-12-23 18:22:59 +08:00
Roman
96843244ae 任务:流程化游戏
*.编写黑块逻辑
(*.具有状态in、all、out
(1.当被呼出,执行呼出事件
((1.分type执行“入”的Tween动画
((2.入动画结束后,修改自身状态至all
((3.等待一定的加载时间后,修改自身状态为out,并开始出动画
((4.出动画结束后,找到“开幕演出”游戏物体,找到它的Stage并触发
((5.完成善后工作,将块移回原来的位置
(2.start时,检查场景内是否有其他转场块。若有,删除自己

1.制作转场
(1.触发转移
(2.关闭操作地图
(4.令玩家一直向右移动
(3.呼出黑块
(4.等待、直到黑块进入全覆盖状态
(5.根据字典经行场景转移
(6.黑块内部协程级时结束后,揭开黑幕
(7.揭开动画结束后
(8.找到“开幕演出”游戏物体,找到它的Stage并触发

3.流程化游戏
(1.将各个场景简单连接

4.修改各场景开幕演出,使开幕演出时修改玩家位置至指定位置

5.制作和替换美术素材,增加部分动画
(1.制作地藏石像动画

*优化和修复
1.修复佛教前置关陷阱小怪抽动的问题
2.修复佛教前置关掉怪陷阱下落太慢的问题

建议:
1.给普通关卡和村也加上类似Boos的全局shader,目前从关卡间过度的时候能够看出明显的区别
2.建议给地藏敲钟攻击的灰尘加上渐隐,目前是瞬间消失的,十分违和
3.建议给普通的炸弹也加上拖尾,很酷
4.以撒发怒时变红太快了,消散得也太快了
5.以撒鬼魂的粒子也建议加上淡入和淡出

*.至此,已经基本完成了游戏的流程化,已经能够顺利地连成一条线了,并且可以在关卡失败的时候在当前场景重生
*.接下来就是填充剧情和美化场景,明天应该能把数据库互动做好

下班
2021-12-23 01:19:03 +08:00
Roman
f936d7f799 *.编写黑块逻辑
(*.具有状态in、all、out
(1.当被呼出,执行呼出事件
((1.分type执行“入”的Tween动画
((2.入动画结束后,修改自身状态至all
((3.等待一定的加载时间后,修改自身状态为out,并开始出动画
((4.出动画结束后,找到“开幕演出”游戏物体,找到它的Stage并触发
((5.完成善后工作,将块移回原来的位置

1.制作转场
(1.触发转移
(2.关闭操作地图
(4.令玩家一直向右移动
(3.呼出黑块
(4.等待、直到黑块进入全覆盖状态
(5.根据字典经行场景转移
(6.黑块内部协程级时结束后,揭开黑幕
(7.揭开动画结束后
(8.找到“开幕演出”游戏物体,找到它的Stage并触发
2021-12-22 11:17:21 +08:00
Roman
5b28c9a977 Squashed commit of the following:
commit bb3be793ca5db3df43679f2d6c34c75f768047a1
Author: SAIPO <grasste0403@hotmail.com>
Date:   Wed Dec 22 07:46:07 2021 +0800

    修改佛教Boss关卡和伊斯兰Boss关卡的粒子特效

commit 1987a63954402be8894f9cc9805545432afefa18
Author: SAIPO <grasste0403@hotmail.com>
Date:   Tue Dec 21 20:55:05 2021 +0800

    任务:编写shader,完善数据库类
    1.完善了PlayerInfo类,用以数据库功能
     1) 编写GetSqlData()函数,使用多线程获取用户信息,使用前请先设置公关变量name。
     2) 编写CreateUser(string username)函数,在用户表内创建一个用户。
     3) 编写hasName(string _searchName)函数,判断是否存在这个用户。
     4) 编写GetBoardInfo(int WorldId)函数,获取指定世界的留言板链表。
     5) 编写GetDeadInfo(int WorldId)函数,获取指定世界的死亡信息链表。
     6) 编写CreateDead(int WorldId, Vector2 postion)函数,创建一条死亡信息。
     7) 编写CreateBoard(int WorldId, Vector2 postion,string text)函数,创建一条留言信息。
     8) 编写UpdatePlayerInfo()函数,将类里储存的信息上传到数据库。

    2.实装相关Shader
     1)完善以撒关卡的屏幕后特效,使其可以在发怒场景发出红色辉光。
     2)完善以撒鬼魂的粒子,并且颜色和发怒与否关联。
     3)实装以撒关卡的窗户辉光效果。
     4)实装伊斯兰Boss关卡炸弹弹反的粒子特效。
     5)实装伊斯兰Boss关卡的尘土特效(需要重做)
     6)实装佛教Boss关卡的敲钟声波特效。
     7)实装佛教Boss关卡的钟声受击灰尘(需要重做)

    3.目前发现的bug
     1)当人物恰好调到角落里会卡动画。
     2)伊斯兰Boss关卡,特洛伊木马吐出的炸弹落到特效小怪上会闪退。

commit c06b842382051bc260d9f509491c683a41ca2a4c
Author: SAIPO <grasste0403@hotmail.com>
Date:   Tue Dec 21 14:08:06 2021 +0800

    Squashed commit of the following:

    commit e7dcdec1d9913e283f42d42f72f1030f0c8b6fda
    Author: Roman <1325980292@qq.com>
    Date:   Tue Dec 21 00:45:50 2021 +0800

        任务:搭建前置关卡,编写演出逻辑

        1.流程化游戏
        (1.制作转移器,内含字典,根据玩家的静态属性“阶段”来决定到转移点后将会移动到哪一个场景
        (2.制作转场器,水平方向从左到右

        下班

    commit 74f926815ec8d00fa051192eb3b978ff4b3c01a6
    Author: Roman <1325980292@qq.com>
    Date:   Mon Dec 20 23:33:14 2021 +0800

        任务:搭建前置关卡,编写演出逻辑

        1.编写基督前置关卡
        (1.放置平台、怪物和男童
        (2.修改男童类,外加OnSaveEvent,OnSave时若有事件则触发该Event
        (3.编写开幕演出,与yi前置类似
        (4.编写男童解救演出
        ((1.触发Fungus对话
        ((2.对话结束后,开启通往上层的门

        2.搭建村场景
        (1.放置平台和元素
        (2.为可动元素制作动画

        3.为玩家添加static属性,进度。0:刚开,1进村,2通佛,3通伊,4.通基

        4.制作死亡重开功能
        (1.当玩家生命值降到0及以下,触发死亡事件
        (2.死亡后reload当前场景,并设记录员,关闭某些事件和演出不再执行

        *优化和修复
        (1.尝试制作击中卡肉效果,目前打击感太弱。也可以尝试粒子效果

        *至此,全部前置关卡搭建完毕,村场景搭建完毕。
        *明天可以完成流程化,接下来就是填充剧情、UI、死亡标记和留言板等系统了

        下班

    commit f257b40d10373a13380e9c395fe94d6559a82a0f
    Author: Roman <1325980292@qq.com>
    Date:   Sun Dec 19 23:57:44 2021 +0800

        任务:搭建前置关卡,编写演出逻辑

        1.编写佛教前置关开场演出
        (*.休整地形,使得左边多出一块地面,方便演出正常运作
        (*.项目后期再通过逻辑触发该演出,目前先用调试方式触发演出
        (1.关闭空气墙
        (2.修改玩家inputDir使玩家从屏幕外冲进到屏幕内部
        (3.等待一段时间
        (4.此时玩家应该走到某个合适的位置,停止玩家的inputDir
        (5.等待一小段时间给玩家反应
        (6.修改相机offset,使其对准对话的两个小怪
        (7.等待一小段时间给玩家反应
        (8.触发Fungus对话
        (9.Fungus对话结束后,返回标记命令演出Main继续执行
        *.修改NormalEnemy,添加标识isInFoStage,在Update中判断,若是,使该怪物水平方向上追踪玩家,可以参考爱欲品的Seek
        (10.修改左边小怪的isInFoStage
        (11.开启右边小怪的Path动画,表现其慌忙逃跑
        (12.Invoke一个延时,等右边小怪逃出视野后删除它
        (13.触发善后和结束事件
        (14.重写善后事件,重新开启空气墙

        2.搭建伊斯兰前置关卡

        3.创建伊斯兰前置关卡演出
        (1.关闭空气墙
        (2.修改玩家inputDir使玩家从屏幕外冲进到屏幕内部
        (3.等待一段时间
        (4.此时玩家应该走到某个合适的位置,停止玩家的inputDir
        (5.等待一小段时间给玩家反应
        (6.触发善后与结束事件

        4.创建玩家隔间触发事件
        (1.是进入式触发器对象
        (2.触发时Call隔间演出

        5.编写隔间演出逻辑
        (1.表现关门
        (2.左右晃一下镜头,中心移动到左右门处,表示门被关闭
        (3.镜头回到玩家处,同时压缩相机可移动范围更窄
        (4.打开隔间墙壁的空气墙
        (5.设置EndEvent为伊斯兰事件

        6.编写召唤伊斯兰事件
        (1.摘自木马的召唤攻击,稍作修改
        (2.当召唤的伊斯兰全部挂了,触发隔间结束事件

        7.编写隔间结束事件
        (1.表现开门
        (2.关闭隔间的空气墙
        (3.重设相机移动范围

        8.搭建基督前置关卡

        *.至此,第一关、第二关前置关卡的逻辑基本开发完毕

        *.明天能做完所有前置关,顺便应该能搭完村场景,后天可以开始搭建新系统,目前还差留言、死亡标记等系统等待编写

        下班

    commit cd22966ad7637a84c0f08c3a716d5ec549699749
    Author: Roman <1325980292@qq.com>
    Date:   Sun Dec 19 14:12:05 2021 +0800

        Squashed commit of the following:

        commit 26aff356971bdc2c2a6a3bd444eeb50c4bf7ec14
        Author: SAIPO <grasste0403@hotmail.com>
        Date:   Sun Dec 19 02:20:44 2021 +0800

            导入近期制作的一些Shader
            1.合并分支
            2.完成了人物描边的流动shader制作,并且可以对Bloom屏幕后处理产生反应。
            3.完成了基督教boss关卡,彩色窗户辉光的shader制作,可以对Bloom产生反应。
            4.完成了伊斯兰教弹反的炸弹拖尾粒子shader的制作。
            5.完成了火焰粒子shader的制作(可以用在基督教的以撒鬼魂上)。
            6.完成了灰尘粒子像素化的shader制作。
            7.完成了边缘扭曲的shader制作,可以用在一些树木上,让画面产生动感。

            明天制作敲钟的声波Shader

    # Conflicts:
    #	UserSettings/EditorUserSettings.asset

commit 26aff356971bdc2c2a6a3bd444eeb50c4bf7ec14
Author: SAIPO <grasste0403@hotmail.com>
Date:   Sun Dec 19 02:20:44 2021 +0800

    导入近期制作的一些Shader
    1.合并分支
    2.完成了人物描边的流动shader制作,并且可以对Bloom屏幕后处理产生反应。
    3.完成了基督教boss关卡,彩色窗户辉光的shader制作,可以对Bloom产生反应。
    4.完成了伊斯兰教弹反的炸弹拖尾粒子shader的制作。
    5.完成了火焰粒子shader的制作(可以用在基督教的以撒鬼魂上)。
    6.完成了灰尘粒子像素化的shader制作。
    7.完成了边缘扭曲的shader制作,可以用在一些树木上,让画面产生动感。

    明天制作敲钟的声波Shader

# Conflicts:
#	Assets/Scenes/TeLuoYiStageTest.unity
#	Assets/Shader/火焰粒子shader/particle.shadergraph
#	Assets/Shader/灰尘粒子用shader/Pixel_My.shader
#	Assets/Shader/灰尘粒子用shader/Unlit_Pixel_My 1.mat
#	Assets/Shader/灰尘粒子用shader/Unlit_Pixel_My 2.mat
#	Assets/Shader/灰尘粒子用shader/Unlit_Pixel_My.mat
#	Logs/ApiUpdaterCheck.txt
#	UserSettings/EditorUserSettings.asset
2021-12-22 10:01:30 +08:00
Roman
e7dcdec1d9 任务:搭建前置关卡,编写演出逻辑
1.流程化游戏
(1.制作转移器,内含字典,根据玩家的静态属性“阶段”来决定到转移点后将会移动到哪一个场景
(2.制作转场器,水平方向从左到右

下班
2021-12-21 00:45:50 +08:00
Roman
74f926815e 任务:搭建前置关卡,编写演出逻辑
1.编写基督前置关卡
(1.放置平台、怪物和男童
(2.修改男童类,外加OnSaveEvent,OnSave时若有事件则触发该Event
(3.编写开幕演出,与yi前置类似
(4.编写男童解救演出
((1.触发Fungus对话
((2.对话结束后,开启通往上层的门

2.搭建村场景
(1.放置平台和元素
(2.为可动元素制作动画

3.为玩家添加static属性,进度。0:刚开,1进村,2通佛,3通伊,4.通基

4.制作死亡重开功能
(1.当玩家生命值降到0及以下,触发死亡事件
(2.死亡后reload当前场景,并设记录员,关闭某些事件和演出不再执行

*优化和修复
(1.尝试制作击中卡肉效果,目前打击感太弱。也可以尝试粒子效果

*至此,全部前置关卡搭建完毕,村场景搭建完毕。
*明天可以完成流程化,接下来就是填充剧情、UI、死亡标记和留言板等系统了

下班
2021-12-20 23:33:14 +08:00
Roman
f257b40d10 任务:搭建前置关卡,编写演出逻辑
1.编写佛教前置关开场演出
(*.休整地形,使得左边多出一块地面,方便演出正常运作
(*.项目后期再通过逻辑触发该演出,目前先用调试方式触发演出
(1.关闭空气墙
(2.修改玩家inputDir使玩家从屏幕外冲进到屏幕内部
(3.等待一段时间
(4.此时玩家应该走到某个合适的位置,停止玩家的inputDir
(5.等待一小段时间给玩家反应
(6.修改相机offset,使其对准对话的两个小怪
(7.等待一小段时间给玩家反应
(8.触发Fungus对话
(9.Fungus对话结束后,返回标记命令演出Main继续执行
*.修改NormalEnemy,添加标识isInFoStage,在Update中判断,若是,使该怪物水平方向上追踪玩家,可以参考爱欲品的Seek
(10.修改左边小怪的isInFoStage
(11.开启右边小怪的Path动画,表现其慌忙逃跑
(12.Invoke一个延时,等右边小怪逃出视野后删除它
(13.触发善后和结束事件
(14.重写善后事件,重新开启空气墙

2.搭建伊斯兰前置关卡

3.创建伊斯兰前置关卡演出
(1.关闭空气墙
(2.修改玩家inputDir使玩家从屏幕外冲进到屏幕内部
(3.等待一段时间
(4.此时玩家应该走到某个合适的位置,停止玩家的inputDir
(5.等待一小段时间给玩家反应
(6.触发善后与结束事件

4.创建玩家隔间触发事件
(1.是进入式触发器对象
(2.触发时Call隔间演出

5.编写隔间演出逻辑
(1.表现关门
(2.左右晃一下镜头,中心移动到左右门处,表示门被关闭
(3.镜头回到玩家处,同时压缩相机可移动范围更窄
(4.打开隔间墙壁的空气墙
(5.设置EndEvent为伊斯兰事件

6.编写召唤伊斯兰事件
(1.摘自木马的召唤攻击,稍作修改
(2.当召唤的伊斯兰全部挂了,触发隔间结束事件

7.编写隔间结束事件
(1.表现开门
(2.关闭隔间的空气墙
(3.重设相机移动范围

8.搭建基督前置关卡

*.至此,第一关、第二关前置关卡的逻辑基本开发完毕

*.明天能做完所有前置关,顺便应该能搭完村场景,后天可以开始搭建新系统,目前还差留言、死亡标记等系统等待编写

下班
2021-12-19 23:57:44 +08:00
Roman
cd22966ad7 Squashed commit of the following:
commit 26aff356971bdc2c2a6a3bd444eeb50c4bf7ec14
Author: SAIPO <grasste0403@hotmail.com>
Date:   Sun Dec 19 02:20:44 2021 +0800

    导入近期制作的一些Shader
    1.合并分支
    2.完成了人物描边的流动shader制作,并且可以对Bloom屏幕后处理产生反应。
    3.完成了基督教boss关卡,彩色窗户辉光的shader制作,可以对Bloom产生反应。
    4.完成了伊斯兰教弹反的炸弹拖尾粒子shader的制作。
    5.完成了火焰粒子shader的制作(可以用在基督教的以撒鬼魂上)。
    6.完成了灰尘粒子像素化的shader制作。
    7.完成了边缘扭曲的shader制作,可以用在一些树木上,让画面产生动感。

    明天制作敲钟的声波Shader
2021-12-19 14:12:05 +08:00
Roman
62459078a4 任务:搭建前置关卡,编写演出逻辑
1.搭建佛教前置关卡
(1.替换浮空平台贴图
(*.制作普通小怪的预制体
(*.制作普通小怪动画
(2.编写掉怪陷阱

2.编写演出类逻辑
(1.继承自Event
(2.具有结束事件(Event对象
(3.OnCall演出时,先做一些演出的基本准备工作
((1.修改玩家的操作地图
((*.后续慢慢完善
(4.准备工作结束后startContinue演出主体
(5.演出主体的结尾触发自身End事件和结束事件(Event对象

*.修复和优化
(1.修复爱欲品wander状态无法被正常击飞的问题
(2.修复玩家蹭墙也标记着地的问题
(3.修复玩家在下降中的平台会抖动的问题
(4.修复玩家状态机偶尔不会触发下落动画的问题

*.今日通过了导出测试

*.顺利的话明天能够完成第一关的所有演出

下班
X﹏X
2021-12-19 01:31:23 +08:00
Roman
2092d46d9e 任务:替换美术素材,实装动画
1.搭建佛教前置关卡
(1.制作地形碰撞体
(2.安排两个巡逻的爱欲品
(3.创建5个来回反复浮动的浮空平台

*.修复和优化
(1.修复被爱欲品附身后脚滑的问题
(2.修复爱欲品在复杂地形下行动速度异常问题

!:爱欲品无法被击飞问题等待修复,目测是Seek的问题

明天编写演出类框架
下班
2021-12-18 01:50:59 +08:00
Roman
5a5a0e220b 任务:替换美术素材,实装动画
1.替换一些美术素材
(1.替换炸弹贴图

2.实装一些新动画
(1.制作地藏之手拿钱的时候的动画
(2.制作爱欲品小怪动画
(3.制作伊斯兰小怪动画
(4.制作玩家开始交互和交互中动画
(5.制作镰刀飞行动画
(6.制作男童动画

*.优化和修复
(1.使木马喷射炸弹时,炸弹有扭矩
2021-12-17 23:33:40 +08:00
Roman
7914126975 任务:搭建基本的系统
1.编写以撒的受击逻辑
(1.利用基类的受击逻辑
(2.具有开关表示此时是否狂暴
(3.重写以撒的onBeHit
((1.当此时狂暴,能够被攻击,模仿其他怪物受击逻辑,并触发狂暴解除函数
((2.当未狂暴,虽然击中,但是无事发生
(4.完善解救男童逻辑,当有男童被解救且未处于狂暴状态,使其狂暴
(5.编写狂暴函数,当触发狂暴时:
((1.将其攻击间隔时间改为狂暴时攻击间隔
((2.修改生成鬼魂时的逻辑,使其生成时加上一个颜色向量,控制其红色通道。通常状态向量为0,狂暴状态修改向量为红色。
((3.石像开始高频率低幅度震动
(6.编写狂暴解除功能
((1.恢复攻击间隔至普通攻击间隔
((2.修改狂暴颜色向量为零向量
((3.停止石像震动

2.修改鬼魂的攻击逻辑,只有当冲撞的时候会开启碰撞体

*:修复Bug:
(1.修复鬼魂使用落雷时,无法正确找到场景内的落雷物体的问题
(2.修复被攻击时仍能继续解救男童的问题

至此,以撒的Boss逻辑基本开发完毕
至此,三个Boss的逻辑均基本开发完毕
2021-12-17 19:54:50 +08:00
Roman
ca9a746b76 任务:搭建基本的系统
1.编写以撒逻辑
(1.继承于Enemy
(2.编写OnSave(男童)事件,当有男童被解救,会触发以撒的这个事件,后续逻辑等待讨论
(3.具有冲撞和闪电两种攻击方式,通过类似地藏的方式轮回随机决定攻击方式
(4.编写冲撞攻击逻辑
((*.创建鬼魂脚本
((*.创建鬼魂预制体,需要内含触发器
((1.当执行,以玩家为中心向周围一圈固定距离随机方向的某处召唤鬼魂,并记录下此时自身到玩家的方向
((2.等待一小段时间,令鬼魂以记录方向冲撞出去,利用Tweener动画营造一种先抖一下然后猛地创过来的感觉
((3.动画结束后,鬼魂逐渐消隐
((4.消隐结束后,删除游戏物体
((5.冲撞过程中具有攻击判定,若创到玩家,触发玩家的受击事件,同时获取主人的攻击力传给玩家
(3.编写闪电攻击逻辑
((1.当执行,在玩家头顶一定距离处生成鬼魂
((2.淡入显示鬼魂,一小段时间后,命令鬼魂发动落雷攻击
((3.发动时,激活场景内的巨型落雷,同时更改落雷的x位置到鬼魂的x,子物体具有触发器,(每帧)检测到玩家在内则对玩家造成伤害
((4.在极短的时间后关闭落雷同时开始淡出鬼魂
((5.淡出结束后删除游戏物体

2.编写男童逻辑
(1.继承于Interactive
(2.编写解救男童逻辑
((*.修改Interactive基类,新增OnCallCancel事件,当交互键抬起时触发一次
((*.新增男童状态的枚举类型,包含:wait、saving、OK三个状态
((*:新增一个变量记录男童状态
((1.重写OnCall事件,当OnCall,修改状态至saving
((2.Update回调中,若处于saving状态,则开始减少CDLeft,同时判断CDLeft是否耗尽,若耗尽,触发OnSave
((3.编写OnSave函数,修改状态至OK,通知owner自己已经OnSave
((4.重写OnCallCancel事件,当触发,判定状态,若处于saving状态,则修改状态至wait,恢复CDLeft
((*.使得玩家救人的时候无法移动,而当交互键抬起,重新获得移动能力
((*.修改可交互基类,当玩家交互过程中丢失catching,触发可交互物体的中断,同时告知玩家交互中断,触发中断事件
((5.解救结束后,通知玩家解救结束

至此,以撒的Boss逻辑还差首尾部分
加速吧
2021-12-17 01:27:10 +08:00
Roman
1cfe5ef4c0 任务:搭建基本的系统
1.替换和适配地藏关卡美术资源
2.编写玩家被敲钟攻击逻辑
(1.当钟抬起到落下期间,中幅度震动手柄和屏幕
(2.当撞钟能攻击到玩家,触发玩家annoying事件,当不能,且玩家正处于annoying状态,则触发玩家Outannoying事件。annoying事件中修改玩家beannoying标记,并编写减速减益状态,Outannoying事件中修改标记,并还原减益。Update中,若处于beannoying状态,则减少受击CDLeft,若CDLeft降到0以下则受击并击飞,并重置受击CDLeft。
(3.当撞钟攻击结束时玩家任然处于被干扰状态,触发玩家的脱离干扰事件
3.修改震动管理员类,新建一种无法被覆盖的震动
4.伸手的时候中幅度震动手柄和屏幕
5.修改敲钟攻击逻辑,使得敲钟时玩家无论在何处都要减速
6.手被攻击的时候中幅度震动手柄和屏幕
2021-12-15 00:07:36 +08:00
Roman
9b4871b128 任务:搭建基本的系统
1.完成召唤炸弹攻击逻辑
(1.参照其他两种攻击,延时循环3次
(2.在起点和终点之间的x范围内的随机位置生成炸弹,y轴绑定起点

(*.修改炸弹类,使其右变量控制落地后的爆炸时间,默认为0,初始化时可以更改。新增判断,如果落地,执行延时而非直接爆炸

(3.初始化炸弹,给其向下微微偏左的初速度,这种炸弹会滚动,修改其落地后爆炸的时间

2.完成反击炸弹逻辑
(1.给玩家添加子物体:反击侦察器,内含圆形触发器
(2.给MyPlayer添加工具类,反击侦察器,初始化的时候找到该子物体并赋予其组件
(3.编写反击侦察器逻辑,内含一对触发器逻辑,当有炸弹进入反击范围,记录可反击炸弹,离开则清空
(4.编写玩家反击判定。当按下攻击键,额外检查反击侦察器是否有炸弹可以反击,如果有,再检查面部朝向,只有面朝左侧,也就是面朝木马,才能则执行反击

3.完成木马的被打断逻辑
(1.被炸事件触发时修改自身标记被打断
(2.若处于被打断状态,break出喷射循环,呼叫攻击结束事件

4.修复炸弹捕捉攻击对象错误Bug

5.木马创到人的时候,让人受伤

6.添加一些手柄震动
(1.当成功反弹炸弹,剧烈震动手柄

至此,伊斯兰Boss关的逻辑基本开发完毕

7.搭建基督Boss关测试场景
(1.加入一些必要元素
2021-12-14 01:33:24 +08:00
Roman
6253bd856c 任务:搭建基本的系统
1.实装一些美术素材

2.完成木马召唤小怪攻击逻辑
(1.修复伊斯兰小怪的炸飞方向丢失Bug
(2.给伊斯兰小怪两种被击飞模式,当被普通武器攻击,轻度正常击飞,当被炸弹炸飞,剧烈飞出

3.完成木马喷射炸弹攻击逻辑
(1.与召唤小怪逻辑类似
(2.创建炸弹类
(3.3次喷射,仅确定首次力度和方向,后两次依靠倍率改变力度

4.完成炸弹逻辑,用于召唤炸弹和喷射炸弹两种攻击方式
(1.碰到东西即爆炸
(2.有一个触发器表示爆炸范围,当有东西进入
,尝试获取被炸对象接口,如果有,则将其加入攻击列表,爆炸时对列表中的每一个对象造成伤害,攻击力来自于owner
(3.当有物体离开触发器,康康它是否在列表中,若在,将其移除

5.整理脚本

下班
2021-12-12 23:40:14 +08:00
Roman
07d619494b 任务:搭建基本的系统
1.优化一些手感和战斗效果
(1.走动时轻微震动手柄(通过动画Event实现,以匹配脚步)
(2.被打的时候剧烈震动手柄,中幅度震动屏幕
(3.锤子击中的时候中幅度震动手柄
(*.完善震动管理员逻辑以解决震动的覆盖问题
(4.发射镰刀的时候轻微震动手柄,轻微震动屏幕
(5.为发射镰刀添加动画
(6.为锤子的空挥添加轻微震动

2.创建木马BossStageTest场景
(1.创建一些必要的元素
(2.创建木马逻辑组件

3.编写木马逻辑
(1.继承自Enemy
(2.参考地藏逻辑,做出三种攻击的协程
(3.让木马动起来,始终向右
(4.让相机上下轻微震动起来
(5.让手柄一直震动,模拟大型物体的感觉
(6.将空气墙绑在马身上
(7.编写召唤小怪的攻击方式
(*:当触发召唤小怪的攻击,在视野右边,每隔若干随机时间生成一个伊斯兰,生成到指定数量后,发送攻击结束信号。

4.编写地面逻辑
(1.让地面能够无限向右平铺
(*:在地面的末端安排一个触发器,当木马完全离开触发器,使地面移动至地面宽度两倍的右边
(2.将光源绑在地面,这样不会出现远了会失去光照的问题

*:目前伊斯兰小怪在BossStage有一些Bug,明天再修吧
2021-12-12 02:08:39 +08:00
Roman
37ccc08c85 任务:搭建基本的系统
1.编写塞钱箱逻辑
(1.初始为有钱
(2.创建事件,当被塞钱,修改塞钱箱状态
(3.创建事件,当被拿钱,修改塞钱箱状态
(*:修改塞钱箱继承自普通可交互物体

2.编写玩家塞钱逻辑
(1.创建交互按键,当检测到交互执行,执行所catch物体的OnCall,根据所catch物体不同触发不同的动作。当catch到的是塞钱箱,执行塞钱功能
(2.创建塞钱功能,持有特殊金币-1

3.修改爱欲品掉钱逻辑
(1.修改死亡事件,当检测到主人为地藏并且玩家身上已经没钱了的时候,生成一个特殊硬币

4.编写特殊硬币逻辑
(1.继承于可交互物体(×)
(2.OnCall的时候触发玩家加钱功能
(3.物理层上不与除地面以外的其他东西碰撞
(4.捡拾上,给硬币添加一个子物体,通过子物体上的触发器和攻击类来判断捡拾与否

5.编写地藏拿钱攻击逻辑
(*.参照钟的逻辑
(1.新建地藏手
(2.新建组件:地藏手
(3.收到攻击信号后,从外部从上至下伸入一只手,伴随抖动,到一定位置后停止
(4.手有碰撞体,触碰到玩家时,对玩家造成伤害
(5.抄一段普通怪物的受击逻辑,当手被攻击了,触发动画,稍微抬起一小段,并且剧烈震动,同时通知主人被打

6.整理脚本

至此,关卡已经能按照正常的逻辑跑起来了
2021-12-11 02:12:12 +08:00
Roman
5bff5da713 任务:搭建基本的系统
1.修改爱欲品类,解决多个附身的问题
(1.已有变量标记玩家是否正被抓着
(*.当玩家被爱欲品抓住,让玩家记住这个爱欲品,用来后面被多个缠上时清空它的挣脱次数
(2.当爱欲品创到玩家,检查目前是否已经被附身,若是,使用父类的touched函数,也就是普通小怪的,用来创飞玩家,同时,清空当前附身着的爱欲品的挣脱次数
(3.修改爱欲品附身时的跟踪方式,原先为一次定位后不再更改,但如果遇到多只爱欲品的情况,则可能被击飞,此时附身中的爱欲品不会跟踪。修改至攻击中每帧重新定位。

2.编写地藏的敲钟攻击逻辑
(1.钟上浮Tween动画
(2.Tween动画结束事件,开启开关,同时StartContinue,等待一定时间后关闭开关,用来触发攻击结束事件
(3.开关打开时,每帧向玩家发射射线,若能击中玩家,受伤方式等待讨论确认。若不能,则无事可做。

3.整理脚本结构,编写注释、摘要和分层

至此,地藏的敲钟攻击逻辑基本完成
2021-12-10 00:23:50 +08:00
Roman
b1063a379f 任务:搭建基本的系统
1.搭建地藏测试场景
(1.放置单向平台
(2.限制摄像机范围
(3.设置相机跟踪
(4.放置图片素材

2.编写地藏boss逻辑
(1.继承自Enemy(内含基本的变量和事件)
(2.当玩家进入戒备范围,startContinue攻击功能

3.创建塞钱箱脚本,目前为空,仅调试用

4.编写召唤攻击逻辑
(1.编写工具类,投掷点,记录投掷力度、方向。
(2.在地藏中保存两套投掷点
(3.攻击时判定玩家位置,进而决定要使用哪一套投掷点
(4.从投掷点获取信息,然后初始化生成的爱欲品
(5.等待召唤攻击的后摇时间,然后发信号表示攻击结束,进入下一个循环

至此,佛教Boss的召唤攻击方式基本开发完毕
2021-12-08 23:52:17 +08:00
Roman
5c0502497d 似乎成功合并了分支 2021-12-08 19:13:08 +08:00
Roman
83f327571f 任务:搭建基本的系统
1.搭建地藏测试场景
(1.放置单向平台
(2.限制摄像机范围
(3.设置相机跟踪
(4.放置图片素材

2.编写地藏boss逻辑
(1.继承自Enemy(内含基本的变量和事件)
(2.当玩家进入戒备范围,startContinue攻击功能

3.创建塞钱箱脚本
2021-12-08 18:56:47 +08:00
Roman
1619bedd77 任务:搭建基本的系统
1.编写基督小怪逻辑
(1.继承自爱欲品类(巡逻、发现、追踪、击飞、被击飞、死亡、转身等功能)
(2.重写Seek函数,因为爱欲品是一直Seek到玩家位置,而基督需要保留一定距离
((1.Seek时判断基督小怪与玩家的距离,同时指定一个public变量代表攻击范围。若此距离小于攻击范围,触发攻击事件,否则移动位置靠近player

(3.重写OnTouchThePlayer事件,使其与NormalEnemy一致
(4.新增攻击事件
((1.修改状态为atk
((2.创建一个基督闪电攻击器,作为预制体保存在JiDu中
((3.初始化攻击器
((4.等待攻击器触发攻击完毕信号,触发恢复事件(无语句)

(5.新增恢复事件
((1.修改状态为Seek

*:效果:依次降下指定数量的雷(触发器判定区),前一个结束后下一个才开始
2.编写攻击器逻辑,可以指定闪电道数、闪电位置间隔、两道闪电之间的间隔时间、每道闪电的持续时间、闪电的判定范围、攻击后硬直

*:整理脚本,添加注释、摘要、分层和属性特性

至此,基督小怪的逻辑开发完毕

至此,所有小怪的逻辑均开发完毕

通过导出测试

下班
2021-12-07 21:39:49 +08:00
Roman
7d2c965521 任务:搭建基本的系统
1.编写伊斯兰小怪逻辑
(1.继承于Enemy类
(2.初始化时直接为Seek状态
(3.每帧执行Seek函数,让其水平方向有冲向玩家的速度
(4.当触发Touch玩家事件,伊斯兰触发协程Boom
(*.给伊斯兰类添加触发器监听,当玩家进入触发器范围,标记可以炸到玩家;当玩家离开触发器,标记无法炸到玩家
(5.当Boom执行时,标记自身为dead,关闭自身碰撞体,抄一下NormalEnemy的被击飞函数,并使刚体开始旋转。同时判定玩家是否可被炸到,若能,击飞玩家并造成相对的伤害值。
(6.从NormalEnemy代码复制过来了受击逻辑
*:整理伊斯兰代码

至此,伊斯兰小怪的逻辑基本开发完毕

*修复攻击时能够转身的问题

2.编写屏幕和手柄震动相关逻辑
(1.设计震动类
(2.设计静态方法ShakeScream和ShakePad,其中ShakePad为协程,调用时请使用StartContinue。

3.为玩家起跳添加屏幕晃动和手柄震动
2021-12-05 00:40:50 +08:00
Roman
032bef564e 任务:搭建基本的系统
1.完成玩家被爱欲品抓住的逻辑
(1.在玩家类已经留下空事件,需要完成逻辑:当被爱欲品抓住,玩家需要:
((1.声明bool新变量isCatching
((2.更改变量isCatching为true
((3.更改inControl变量为false,此时玩家不再能移动
((4.处理伤害,每秒减去爱欲品的atk的血量
(2.在InputSystem的事件OnMove中,触发转身处,添加一处判定,若此时inControl,才能进行转身操作。若isCatching为真,不触发转身,进而触发爱欲品的挣脱事件。
(*:修改爱欲品完全挣脱事件,使其通知玩家已经完全挣脱
(3.当收到完全挣脱的消息,恢复isCatching为false,同时恢复inControl,同时关闭掉血协程,同时删除记录的抓着玩家的爱欲品

*:至此,爱欲品的行动逻辑基本上开发完成

2.修复玩家用锤子攻击会多次判定到怪物身上的Bug
3.修复玩家挥锤子卡手的问题
4.重新匹配锤子挥动判定与动画
5.修改锤子动画速度曲线
6.解决狂按攻击有概率卡死的问题
7.使玩家攻击的时候无法移动
8.解决玩家被缠抱时可以跳跃的问题
9.解决玩家被缠抱时可以发镰刀的问题

攻击手感很怪,还需要细调
🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔
2021-12-03 23:58:34 +08:00
Roman
5b2e3633ab 任务:搭建基本的系统
1.替换动画源图片为攻击加长版
(*:新建动画“被击飞”并完成状态机逻辑
(*:删除旧动画源图片素材减小项目体积
*:修复攻击动画卡手问题
*:修复被击飞后朝向影响击飞结果的Bug

2.编写佛教小怪逻辑
(1.继承自NormalEnemy(*:与原备注不同,因为后期我发现用NormalEnemy更加合适更加简单)
(2.与普通小怪一样,默认状态会巡逻
(3.当玩家进入感知范围,触发Seek
(4.当玩家创到怪物,触发Atk
(*:改变自身状态为ATK
(*:关闭自身碰撞体,因为要贴在玩家身上
(*:将自身位置和玩家位置同步,但是需要一个附身offset二维向量,因为玩家的图片不在游戏物体的中心
(*:通知玩家,你被爱欲品附身了
(5.当怪物收到伤害,触发Seek
(*:我决定后期根据具体地形完善爱欲品的Seek函数
(6.编写完全挣脱事件
(*:触发死亡事件
(*:死亡后给予随机方向的击飞和旋转
(*:添加public变量breakFreeCount,代表挣脱需要触发多少次方向变换
(*:添加public变量breakFreeCountLeft,代表现在还需要方向变换多少次才能挣脱
(7.添加挣脱行为事件,从player传来,减一点Left并且判断是否完全挣脱,若是则执行完全挣脱事件
3.整理脚本分层,添加摘要和注释

下班,明天写玩家挣脱逻辑和被抓逻辑
🥱🥱🥱🥱🥱🥱🥱🥱🥱🥱🥱🥱🥱🥱🥱🥱🥱🥱
2021-12-03 01:23:07 +08:00
Roman
5105e892f9 Squashed commit of the following:
commit 9b1756077de6fd5005c6d7300b470e2bfa223f97
Author: SAIPO <grasste0403@hotmail.com>
Date:   Thu Dec 2 16:10:18 2021 +0800

    任务:编写屏幕后特效的渲染框架
    1.合并分支
    2.完成框架编写,代码文件在URP文件夹里

commit 994279b09e8676155176aecbcd43f13ab90f2c92
Author: SAIPO <grasste0403@hotmail.com>
Date:   Mon Nov 29 23:59:44 2021 +0800

    任务:编写效果Shader
    1.增加了通过高斯模糊公式实现的高斯模糊shader(建议用在背景层,让画面有一些景深感觉)
    2.增加了像素化的shader,通过在片元着色器上的uv合并,可以使贴图变为像素风格
    3.增加了闪光划过的shader

commit 271e45aeb97212640573a9faf71483cece293043
Author: SAIPO <grasste0403@hotmail.com>
Date:   Mon Nov 29 23:09:30 2021 +0800

    11.29合并分支

commit dfa618fabaf36626e1b92e7ab34c87d497bcdeb3
Author: SAIPO <grasste0403@hotmail.com>
Date:   Sat Nov 27 13:42:16 2021 +0800

    合并分支

commit de8d79b73e560814ff9fc8a0c3418009682c5ef8
Author: SAIPO <grasste0403@hotmail.com>
Date:   Tue Nov 23 21:25:44 2021 +0800

    任务:搭建Mysql数据库相关框架
    1.完成Mysql动态链接库的导入
    2.实现基本的服务器连接数据框架
    3.实现Sql语句查询框架

# Conflicts:
#	.merge_file_a14904
#	.merge_file_a17704
#	Assets/Behavior Designer/Resources.meta
#	Assets/Demigiant/DOTween.meta
#	Assets/Demigiant/DOTween/Editor.meta
#	Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb.meta
#	Assets/Demigiant/DOTween/Modules.meta
#	Assets/Plugins/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb.meta
#	Assets/Prefabs/镰刀.prefab.meta
#	Assets/Scenes/test.unity
#	Assets/Shader.meta
#	Logs/ApiUpdaterCheck.txt
2021-12-02 20:21:03 +08:00
Roman
1802f8ee83 任务:搭建基本的系统
1.绑定cinemaMachine相机
2.修复锤子攻击后玩家反而被击飞的Bug
(1.为了避免锤子碰撞体抵到地面、锤子将怪物按在地上等问题,现需要将锤子改为触发器,锤子的判定代码移至锤子类
2.替换锤子攻击动画为攻击范围加长一版
2021-12-01 19:14:21 +08:00
Roman
c92b8a3e28 任务:搭建基本的系统
1.实装部分美术素材
(1.制作起跳动画
(2.制作下落动画
(3.制作攻击动画
(4.完成状态机和玩家类动画逻辑

上课写码,法力无边
🤔🤔🤔🤔🤔🤔
2021-12-01 09:28:18 +08:00
Roman
2c278680cc 任务:搭建基本的系统
1.实装部分前期美术素材
(1.放置了一个临时背景
2.编写玩家状态机器雏形
(1.创建待机动画
(2.创建跑步动画
(3.将上述动画写入状态机,并编写脚本呼出动画

明天整,睡大觉,欧亚
嘲哳难为听
🥱
2021-11-30 23:08:26 +08:00
Roman
f4b96539c5 Squashed commit of the following:
commit 994279b09e8676155176aecbcd43f13ab90f2c92
Author: SAIPO <grasste0403@hotmail.com>
Date:   Mon Nov 29 23:59:44 2021 +0800

    任务:编写效果Shader
    1.增加了通过高斯模糊公式实现的高斯模糊shader(建议用在背景层,让画面有一些景深感觉)
    2.增加了像素化的shader,通过在片元着色器上的uv合并,可以使贴图变为像素风格
    3.增加了闪光划过的shader

commit 271e45aeb97212640573a9faf71483cece293043
Author: SAIPO <grasste0403@hotmail.com>
Date:   Mon Nov 29 23:09:30 2021 +0800

    11.29合并分支

commit dfa618fabaf36626e1b92e7ab34c87d497bcdeb3
Author: SAIPO <grasste0403@hotmail.com>
Date:   Sat Nov 27 13:42:16 2021 +0800

    合并分支

commit de8d79b73e560814ff9fc8a0c3418009682c5ef8
Author: SAIPO <grasste0403@hotmail.com>
Date:   Tue Nov 23 21:25:44 2021 +0800

    任务:搭建Mysql数据库相关框架
    1.完成Mysql动态链接库的导入
    2.实现基本的服务器连接数据框架
    3.实现Sql语句查询框架

# Conflicts:
#	Assets/Behavior Designer/Resources/BehaviorDesignerGlobalVariables.asset.meta
#	Assets/Demigiant/DOTween/Editor.meta
#	Assets/Fungus/Integrations/Playmaker/Fungus-PlayMaker.unitypackage.meta
#	Assets/Fungus/Integrations/Spine/Fungus-Spine.unitypackage.meta
#	Assets/Plugins/Sirenix/Demos/Custom Attribute Processors.unitypackage.meta
#	Assets/Plugins/Sirenix/Demos/Custom Drawers.unitypackage.meta
#	Assets/Plugins/Sirenix/Demos/Editor Windows.unitypackage.meta
#	Assets/Plugins/Sirenix/Demos/Sample - RPG Editor.unitypackage.meta
#	Assets/Shader.meta
#	Assets/Shader/像素化.meta
2021-11-30 00:50:39 +08:00
Roman
ff4639d2cf 任务:搭建基本的系统
1.编写普通小怪受击逻辑
(1.受击时获得受击方式和受击方向
(*:新建tweenNow变量记录正在播放的动画
(2.受击瞬间停止tweenNow(否则怪物的物理路径将被锁定在tween中
(*:向玩家类中添加字典,用来查询不同攻击方式的攻击倍率
(*:向怪物基类中添加CheckDead功能
(*:编写受击击飞效果,类似于player
(3.减少生命值,同时呼唤CheckDead
(4.若死亡,更改怪物状态为Dead,呼唤OnDead,编写OnDead,给予其范围内随机一个旋转角速度,同时关闭其碰撞体,同时开启一个协程,使其一定时间后被销毁。
(*:给普通怪物添加positionSource变量,记录游戏开始时怪物的位置
(*:给普通小怪类添加inPath变量,记录一下目前是否正在执行path动画
(5.若未死亡,则让怪物着地后Dotween到初始位置,结束后触发事件,重新开始巡逻
(*:修复速度无法控制怪物真实速度的问题
(*:我超,由于插件存在不可忽略的缺陷,要修改怪物的移动速度做不到自动化了,必须通过在Path组件自行输入持续时间,其实就是多做一个小学算数,呐
2021-11-28 23:34:14 +08:00
Roman
405344bdf0 任务:搭建基本的系统
1.编写玩家受击逻辑BeHit(atk,dir)
(1.受击时得知受到的攻击力和受击方向
(2.受击时向受击方向被击飞一小段
(3.减去相应的生命值
2.编写基本小怪逻辑
(1.wander状态,在两点间巡逻
(2.当触发OnTouchThePlayer,通知玩家BeHit
3.编写了更多摘要和参数解释
4.更新的Dotween插件的版本
2021-11-28 01:33:32 +08:00
Roman
f7e92a473d 任务:搭建基本的系统
1.编写敌人基类,具有一些基本属性,往后重复性不是特别大,决定小怪和Boss均继承此类,其余代码写在具体类中。
(1.具有如下属性:
	HP
	HPLeft
	ATK
	Speed
	Coin
	Enmu State(wander\seek\atk\dead)
(2.具有如下事件
OnDead(死亡的时候触发)
OnTouchThePlayer(给予怪物本体碰撞体,当玩家触碰到怪物触发)
OnBeHit(Enmu攻击方式)(当有东西触碰到怪物本体,检测触碰的是什么,然后返回攻击方式给该事件)
OnFindThePlayer(给予怪物一个触发器,当玩家进入该触发器,怪物进入seek状态)

🐎🐎🐎
2021-11-24 23:23:01 +08:00
Roman
3ca9f6d7ea 任务:搭建基本的系统
1.设置转身事件
(1.当触发转身,翻转角色Scale

2.实现发射镰刀功能
(1.发射有CD,CD之内无法再次发射
(2.若未击中怪物,镰刀飞出屏幕后销毁
(3.镰刀飞行方向由玩家发射时面部朝向决定

❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
2021-11-23 23:11:53 +08:00
Roman
9ac9e1fd70 Squashed commit of the following:
commit de8d79b73e560814ff9fc8a0c3418009682c5ef8
Author: SAIPO <grasste0403@hotmail.com>
Date:   Tue Nov 23 21:25:44 2021 +0800

    任务:搭建Mysql数据库相关框架
    1.完成Mysql动态链接库的导入
    2.实现基本的服务器连接数据框架
    3.实现Sql语句查询框架
2021-11-23 21:28:46 +08:00
Roman
07ea6e771c 任务:搭建基本的系统
1.实现挥动锤子功能
(1.有一个挥动过程(DoTween)
(2.判定随着锤子挥动动画进行
(3.挥动起始锤子显现
(4.挥动结束锤子消失
(5.CD之内无法再次挥动(不作反应
(6.挥动过程只能进行UI操作
(7.目前判定范围用sprite表示
(8.只有挥动动画时间内有攻击判定

2.引入Odin插件
2021-11-23 00:22:17 +08:00
Roman
c9e34f623c 任务:搭建基本的系统
1.实现走动
(1.识别摇杆方向给予物体X方向的速度
(2.使用赋予速度的方式使其移动
(3.不管摇杆深度,只管摇杆方向
2.实现跳跃
(1.只能跳跃一段
(2.只有着地的时候能够跳跃
(3.使用赋予速度的方法使其跳跃
3.增大了重力系数以增加2D游戏感
2021-11-21 22:32:29 +08:00
Roman
78aa22c3e2 *:修复了输入系统与Fungus插件冲突的问题 2021-11-21 15:49:17 +08:00
Roman
6b194d05f7 2021-11-21 15:30:24 +08:00
Roman
b4b85b6cd2 Accept Merge Request #1: (master -> 京力)
Merge Request: 🤬

Created By: @Roman
Accepted By: @Roman
URL: https://gensokyogroup.coding.net/p/religion/d/religion/git/merge/1
2021-11-21 15:18:23 +08:00
4011 changed files with 484814 additions and 10665 deletions

41
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,41 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"WARNING01": "*********************************************************************************",
"WARNING02": "The C# extension was unable to automatically decode projects in the current",
"WARNING03": "workspace to create a runnable launch.json file. A template launch.json file has",
"WARNING04": "been created as a placeholder.",
"WARNING05": "",
"WARNING06": "If OmniSharp is currently unable to load your project, you can attempt to resolve",
"WARNING07": "this by restoring any missing project dependencies (example: run 'dotnet restore')",
"WARNING08": "and by fixing any reported errors from building the projects in your workspace.",
"WARNING09": "If this allows OmniSharp to now load your project then --",
"WARNING10": " * Delete this file",
"WARNING11": " * Open the Visual Studio Code command palette (View->Command Palette)",
"WARNING12": " * run the command: '.NET: Generate Assets for Build and Debug'.",
"WARNING13": "",
"WARNING14": "If your project requires a more complex launch configuration, you may wish to delete",
"WARNING15": "this configuration and pick a different template using the 'Add Configuration...'",
"WARNING16": "button at the bottom of this file.",
"WARNING17": "*********************************************************************************",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c07b12ece143f854f9344f036f5450dc
guid: f9f8caaf5133afd49b75b66342f2ecbe
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,106 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-5700492590575048512
MonoBehaviour:
m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 179fc3111e144bc4688dca4038b3265d, type: 3}
m_Name: iPhone Settings
m_EditorClassIdentifier:
m_LoaderManagerInstance: {fileID: 4466775297096079749}
m_InitManagerOnStart: 0
--- !u!114 &-3731449095792271595
MonoBehaviour:
m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 536372c49e1ca914d822849d36de938c, type: 3}
m_Name: Standalone Providers
m_EditorClassIdentifier:
m_AutomaticLoading: 0
m_AutomaticRunning: 0
m_Loaders: []
--- !u!114 &-233813179328996068
MonoBehaviour:
m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 179fc3111e144bc4688dca4038b3265d, type: 3}
m_Name: Standalone Settings
m_EditorClassIdentifier:
m_LoaderManagerInstance: {fileID: -3731449095792271595}
m_InitManagerOnStart: 0
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cb0ece14d1f711a4fb9325ca819dee95, type: 3}
m_Name: AdaptivePerformanceGeneralSettings
m_EditorClassIdentifier:
Keys: 010000000400000007000000
Values:
- {fileID: -233813179328996068}
- {fileID: -5700492590575048512}
- {fileID: 2116847326264649047}
--- !u!114 &2116847326264649047
MonoBehaviour:
m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 179fc3111e144bc4688dca4038b3265d, type: 3}
m_Name: Android Settings
m_EditorClassIdentifier:
m_LoaderManagerInstance: {fileID: 2230240768168764464}
m_InitManagerOnStart: 0
--- !u!114 &2230240768168764464
MonoBehaviour:
m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 536372c49e1ca914d822849d36de938c, type: 3}
m_Name: Android Providers
m_EditorClassIdentifier:
m_AutomaticLoading: 0
m_AutomaticRunning: 0
m_Loaders: []
--- !u!114 &4466775297096079749
MonoBehaviour:
m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 536372c49e1ca914d822849d36de938c, type: 3}
m_Name: iPhone Providers
m_EditorClassIdentifier:
m_AutomaticLoading: 0
m_AutomaticRunning: 0
m_Loaders: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c904ac9773b374d419329ca1a0f380ac
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: e2956dad15d720e4884aabb37c6cca2c
guid: 4c46395d0d61fa24999699eb8129d2d7
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,14 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 921854900f2214d7ab9b1e95d17dbb2b, type: 3}
m_Name: Simulator Provider Loader
m_EditorClassIdentifier:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7a89fb07c30c00f4f979cc026eade4b6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3f992aee61d74ea4099853188306afac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,260 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b592865877cb54284a5d1d88aec9cfbb, type: 3}
m_Name: Simulator Provider Settings
m_EditorClassIdentifier:
m_Logging: 1
m_AutomaticPerformanceModeEnabled: 1
m_StatsLoggingFrequencyInFrames: 50
m_IndexerSettings:
m_Active: 1
m_ThermalActionDelay: 10
m_PerformanceActionDelay: 4
m_ScalerSettings:
m_AdaptiveFramerate:
m_Name: Adaptive Framerate
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 2
m_Target: 7
m_MaxLevel: 45
m_MinBound: 15
m_MaxBound: 60
m_AdaptiveResolution:
m_Name: Adaptive Resolution
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 0
m_Target: 6
m_MaxLevel: 9
m_MinBound: 0.5
m_MaxBound: 1
m_AdaptiveBatching:
m_Name: Adaptive Batching
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 1
m_Target: 1
m_MaxLevel: 1
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveLOD:
m_Name: Adaptive LOD
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 2
m_Target: 2
m_MaxLevel: 3
m_MinBound: 0.4
m_MaxBound: 1
m_AdaptiveLut:
m_Name: Adaptive Lut
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 1
m_Target: 3
m_MaxLevel: 1
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveMSAA:
m_Name: Adaptive MSAA
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 1
m_Target: 6
m_MaxLevel: 2
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveShadowCascade:
m_Name: Adaptive Shadow Cascade
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 1
m_Target: 3
m_MaxLevel: 2
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveShadowDistance:
m_Name: Adaptive Shadow Distance
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 0
m_Target: 2
m_MaxLevel: 3
m_MinBound: 0.15
m_MaxBound: 1
m_AdaptiveShadowmapResolution:
m_Name: Adaptive Shadowmap Resolution
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 0
m_Target: 2
m_MaxLevel: 3
m_MinBound: 0.15
m_MaxBound: 1
m_AdaptiveShadowQuality:
m_Name: Adaptive Shadow Quality
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 2
m_Target: 3
m_MaxLevel: 3
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveSorting:
m_Name: Adaptive Sorting
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 1
m_Target: 1
m_MaxLevel: 1
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveTransparency:
m_Name: Adaptive Transparency
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 2
m_Target: 2
m_MaxLevel: 1
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveViewDistance:
m_Name: Adaptive View Distance
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 2
m_Target: 2
m_MaxLevel: 40
m_MinBound: 50
m_MaxBound: 1000
m_scalerProfileList:
- m_AdaptiveFramerate:
m_Name: Adaptive Framerate
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 2
m_Target: 7
m_MaxLevel: 45
m_MinBound: 15
m_MaxBound: 60
m_AdaptiveResolution:
m_Name: Adaptive Resolution
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 0
m_Target: 6
m_MaxLevel: 9
m_MinBound: 0.5
m_MaxBound: 1
m_AdaptiveBatching:
m_Name: Adaptive Batching
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 1
m_Target: 1
m_MaxLevel: 1
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveLOD:
m_Name: Adaptive LOD
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 2
m_Target: 2
m_MaxLevel: 3
m_MinBound: 0.4
m_MaxBound: 1
m_AdaptiveLut:
m_Name: Adaptive Lut
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 1
m_Target: 3
m_MaxLevel: 1
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveMSAA:
m_Name: Adaptive MSAA
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 1
m_Target: 6
m_MaxLevel: 2
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveShadowCascade:
m_Name: Adaptive Shadow Cascade
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 1
m_Target: 3
m_MaxLevel: 2
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveShadowDistance:
m_Name: Adaptive Shadow Distance
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 0
m_Target: 2
m_MaxLevel: 3
m_MinBound: 0.15
m_MaxBound: 1
m_AdaptiveShadowmapResolution:
m_Name: Adaptive Shadowmap Resolution
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 0
m_Target: 2
m_MaxLevel: 3
m_MinBound: 0.15
m_MaxBound: 1
m_AdaptiveShadowQuality:
m_Name: Adaptive Shadow Quality
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 2
m_Target: 3
m_MaxLevel: 3
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveSorting:
m_Name: Adaptive Sorting
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 1
m_Target: 1
m_MaxLevel: 1
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveTransparency:
m_Name: Adaptive Transparency
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 2
m_Target: 2
m_MaxLevel: 1
m_MinBound: 0
m_MaxBound: 1
m_AdaptiveViewDistance:
m_Name: Adaptive View Distance
m_Enabled: 0
m_Scale: 1
m_VisualImpact: 2
m_Target: 2
m_MaxLevel: 40
m_MinBound: 50
m_MaxBound: 1000
m_Name: Default Scaler Profile
m_DefaultScalerProfilerIndex: 0
k_AssetVersion: 2

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ad690714d07fc1a44849fae3ac890474
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8738ef95994f8ba44b8891af2373c16f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
{
"name": "AmplifyShaderEditor",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f540dafdfbc0586439d98823585550d4
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 580cccd3e608b7f4cac35ea46d62d429
timeCreated: 1481127071
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,58 @@
Creating terrains with Amplify Shader Editor is really quick and easy. We will give you a brief explanation on how you can start creating terrain shaders with ASE in no time.
A standard unity terrain is a regular surface shader using properties with a specific naming.
Besides these properties, a small configuration is necessary.
[Create Shader]
As with any other ASE shaders, right-click on the Project view, select Create > Amplify Shader > Surface Shader and name it as you like. We advise you to have 'First-Pass' included on the shader name since it performs what is called a first pass over the terrain.
[Queue Index]
Set the Queue Index to -100 on the Output Node Properties General tab.
[Render Type]
By default a created shader already comes with the Opaque shader type selected, which is required by the terrain, but please go to the Blend Mode tab and check that Opaque is the selected option.
[Specify Base Shader]
A Base shader must be specified. This shader will be responsible to render the terrain when over a certain distance specified at the Base Map Distance on the terrain settings. Beyond this distance, a lower resolution composite image will be used with this shader for efficiency reasons.
We already have a base shader created and ready to be used, so you only need to:
- Go to your Dependencies Tab on the Output Node Properties
- Click on the Add Button to add a new entry
- Write BaseMapShader into the Name textfield
- Write ASESampleShaders/SimpleTerrainBase on the Value textfield
Feel free to open the ASESampleShaders/SimpleTerrainBase shader located at AmplifyShaderEditor > Examples > Official > SimpleTerrain > SimpleTerrainBase.shader and check what is being done. Please note that property naming in the base shader is very strict and property names must be maintained.
[Specify Splat Count]
ASE only supports up to four splats (single-pass) for now, this needs to be specified into the shader through a custom tag.
In order to do that:
- Go to Custom SubShader Tags tab on the Output Node Properties
- Click on the Add Button to add a new entry
- Write SplatCount into the Name textfield
- Write 4 into the Value textfield
Future versions will introduce multi-pass support for more complex effects.
[Create Properties]
This is the meat of how the terrain shader will behave.
We already have a shader function, Four Splats First Pass Terrain, which replicates Unity standard terrain and should be used as starting point on creating your own shader.
[[Diffuse]]
Each splat can be accessed via their properties, having yet again strict naming to be maintained.
The splat diffuse colors are accessed through the sampler variables _Splat0 through _Splat3, so in your shader you must create four Texture Sampler nodes with the names Splat 0 through Splat 3 as the _ is automatically placed and the empty spaces are also automatically removed from the created variable name.
[[Normal]]
The same goes to normal maps, they are accessed through the sampler variables _Normal0 through _Normal3 so, like with diffuse, in your shader you must create four Texture Sampler nodes with the names Normal 0 through Normal 3. One detail to take into account is that Unpack Normal Map should be turned off for each one of the nodes and an Unpack Scale Normal node should be applied after their values are combined.
[[Smoothness + Metallic]]
Smoothness and Metallic values must also have specific variable names, _Smoothness0 through _Smoothness3 and _Metallic0 through _Metallic3 respectively.
These variables however are Float properties, so to access them you need to create Float nodes, set them to Properties with the names Smoothness 0 through Smoothness 3 and Metallic 0 through Metallic 3 respectively.
To maintain consistency with the Unity terrain shader, you should add the Gamma attribute to the Metallic property nodes.
[[Combining Maps]]
The weight of each layer is given by yet another sampler variable. The _Control sampler variable contains, in each of its channels, the contribution each layer/splat have on the final result.
To get access to it, simply create a Texture Sampler node in your shader with its name being Control.
This Control texture is dynamically created when you paint your terrain with the Terrain tools and can be inspected by selecting the terrain asset on the Project view.
Again, we invite you to check the Four Splats First Pass Terrain shader function located at AmplifyShaderEditor > Plugins > EditorResources > ShaderFunctions > Four Splats First Pass Terrain for a more in-depth view on how the Control texture is used.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f11d5aaf59fc38544b8419242801ff97
timeCreated: 1513615640
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 425c3aed47dd05444960ca41af18e591
folderAsset: yes
timeCreated: 1481126943
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
Fire texture - http://suicidecrew.deviantart.com/art/Fire-Seamless-tile-116721709
Screen Space Curvature - http://madebyevan.com/shaders/curvature/
Grass Blades texture from:
http://www.fuzzimo.com/free-hi-res-ornamental-grass-blade-textures/
Keep them coming, contribute today!
http://amplify.pt/unity/amplify-shader-editor/contribute

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 451790f45b4e5434586d16e924540ee7
timeCreated: 1481127071
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
Use your Unity Asset Store invoice number in the Amplify Product download page to download the latest Amplify Shader Editor package and Shader Samples package.
1 - Go to http://amplify.pt/download
2 - Enter your Unity Asset Store and click Unlock
3 - Scroll down to the Amplify Shader Editor entry
4 - Click the Sample button to download the sample package.
NOTE: You can also use the product download page to download the latest Amplify Shader Editor package. Due to Asset Store review times and update cycles, the version hosted there is usually more recent.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 03fe3bdcb7262a84ca060ff336c7d8d1
timeCreated: 1481127071
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,12 @@
Samples are provided by pipeline, if you want to import the samples please use the "Start Screen" to do so instead of unpacking manually, this will ensure that they are imported correctly. Go to Windows > Amplify Shader Editor > Start Screen and under "Shader Samples" select the ones you want to import. Do be aware that importing any SRP samples requires to first install the respective pipeline using the package manager.
However if you still want to import them manually here is the breakdown of the included packages:
* "Sample Resources": constains the assets shared between all pipelines, like textures and meshes, this should always be imported first
* "Built-In Samples": contains the samples shaders with their scenes for the built-in rendering system
* "HDRP Samples": contains the samples shaders with their scenes for HDRP 7.X.X and up (Unity 2019.3 and up)
* "HDRP Samples (Legacy)": contains the samples shaders with their scenes for HDRP 6.X.X and down (from Unity 2018.2 to Unity 2019.2)
* "URP Samples": contains the samples shaders with their scenes for URP 7.X.X and up (Unity 2019.3 and up)
* "LWRP Samples": contains the samples shaders with their scenes for LWRP between 4.X.X and 6.X.X (from Unity 2018.3 to Unity 2019.2)
* "LWRP Samples (Legacy)": contains the samples shaders with their scenes for LWRP 3.X.X (Unity 2018.2)
Please notice that in some cases the sample may have been created in a different version from the SRP that you are using which can produce "pink" shaders. If that happens it's usually the case that you only need to open the shader in ASE and save it to update it.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5c5208e121a880c4fbb9de7aaeaa8aa2
timeCreated: 1541776170
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3306ce0ede814a84c8d289893da72b7a
folderAsset: yes
timeCreated: 1481126943
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4a66239afbf6d2c4eb99238642c8d40f
folderAsset: yes
timeCreated: 1481126943
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a2ba8588f45692f4ea2fa5afa9faf434
folderAsset: yes
timeCreated: 1481126944
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,336 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyShaderEditor
{
public class ActionData
{
public virtual void ExecuteForward() { }
public virtual void ExecuteReverse() { }
}
// NODES
// Create node
public class CreateNodeActionData : ActionData
{
private int m_nodeId;
private System.Type m_nodeType;
private Vector2 m_nodePos;
public CreateNodeActionData( ParentNode node )
{
m_nodeId = node.UniqueId;
m_nodePos = node.Vec2Position;
m_nodeType = node.GetType();
}
public CreateNodeActionData( int nodeId, System.Type nodeType, Vector2 nodePos )
{
m_nodeId = nodeId;
m_nodePos = nodePos;
m_nodeType = nodeType;
}
public override void ExecuteForward()
{
UIUtils.CreateNode( m_nodeType, false, m_nodePos, m_nodeId );
}
public override void ExecuteReverse()
{
UIUtils.DestroyNode( m_nodeId );
}
public override string ToString()
{
return "Create Node - Type: " + m_nodeType + " Node: " + m_nodeId + " Position: " + m_nodePos;
}
}
// Destroy node
public class DestroyNodeActionData : ActionData
{
private int m_nodeId;
private System.Type m_nodeType;
private Vector2 m_nodePos;
public DestroyNodeActionData( ParentNode node )
{
m_nodeId = node.UniqueId;
m_nodePos = node.Vec2Position;
m_nodeType = node.GetType();
}
public DestroyNodeActionData( int nodeId, System.Type nodeType, Vector2 nodePos )
{
m_nodeId = nodeId;
m_nodePos = nodePos;
m_nodeType = nodeType;
}
public override void ExecuteForward()
{
UIUtils.DestroyNode( m_nodeId );
}
public override void ExecuteReverse()
{
UIUtils.CreateNode( m_nodeType, false, m_nodePos, m_nodeId );
}
public override string ToString()
{
return "Destroy Node - Type: " + m_nodeType + " Node: " + m_nodeId + " Position: " + m_nodePos;
}
}
// Move node
public class MoveNodeActionData : ActionData
{
private int m_nodeId;
private Vector2 m_nodeInitalPos;
private Vector2 m_nodeFinalPos;
public MoveNodeActionData( int nodeId, Vector2 nodeInitialPos, Vector2 nodeFinalPos )
{
m_nodeId = nodeId;
m_nodeInitalPos = nodeInitialPos;
m_nodeFinalPos = nodeFinalPos;
}
public override void ExecuteForward()
{
ParentNode node = UIUtils.GetNode( m_nodeId );
if ( node != null )
node.Vec2Position = m_nodeFinalPos;
}
public override void ExecuteReverse()
{
ParentNode node = UIUtils.GetNode( m_nodeId );
if ( node != null )
node.Vec2Position = m_nodeInitalPos;
}
public override string ToString()
{
return "Move Node - Node: " + m_nodeId + " Initial Position: " + m_nodeInitalPos + " Final Position: " + m_nodeFinalPos;
}
}
// CONNECTIONS
// Create connection
public class CreateConnectionActionData : ActionData
{
private int m_inputNodeId;
private int m_inputPortId;
private int m_outputNodeId;
private int m_outputPortId;
public CreateConnectionActionData( int inputNodeId, int inputPortId, int outputNodeId, int outputPortId )
{
m_inputNodeId = inputNodeId;
m_inputPortId = inputPortId;
m_outputNodeId = outputNodeId;
m_outputPortId = outputPortId;
}
public override void ExecuteForward()
{
UIUtils.ConnectInputToOutput( m_inputNodeId, m_inputPortId, m_outputNodeId, m_outputPortId );
}
public override void ExecuteReverse()
{
UIUtils.DeleteConnection( true, m_inputNodeId, m_inputPortId, false, true );
}
public override string ToString()
{
return "Create Connection Node - Input Node: " + m_inputNodeId + " Input Port: " + m_inputPortId + " Output Node: " + m_outputNodeId + " Output Port: " + m_outputPortId;
}
}
// Destroy connection
public class DestroyConnectionActionData : ActionData
{
private int m_inputNodeId;
private int m_inputPortId;
private int m_outputNodeId;
private int m_outputPortId;
public DestroyConnectionActionData( int inputNodeId, int inputPortId, int outputNodeId, int outputPortId )
{
m_inputNodeId = inputNodeId;
m_inputPortId = inputPortId;
m_outputNodeId = outputNodeId;
m_outputPortId = outputPortId;
}
public override void ExecuteForward()
{
UIUtils.DeleteConnection( true, m_inputNodeId, m_inputPortId, false, true );
}
public override void ExecuteReverse()
{
UIUtils.ConnectInputToOutput( m_inputNodeId, m_inputPortId, m_outputNodeId, m_outputPortId );
}
public override string ToString()
{
return "Destroy Connection Node - Input Node: " + m_inputNodeId + " Input Port: " + m_inputPortId + " Output Node: " + m_outputNodeId + " Output Port: " + m_outputPortId;
}
}
// Move connection
public class MoveInputConnectionActionData : ActionData
{
private int m_oldInputNodeId;
private int m_oldInputNodePortId;
private int m_newInputNodeId;
private int m_newInputNodePortId;
private int m_outputNodeId;
private int m_outputPortId;
public MoveInputConnectionActionData( int oldInputNodeId, int oldInputPortId, int newInputNodeId, int newInputPortId, int outputNodeId, int outputPortId )
{
m_oldInputNodeId = oldInputNodeId;
m_oldInputNodePortId = oldInputPortId;
m_newInputNodeId = newInputNodeId;
m_newInputNodePortId = newInputPortId;
m_outputNodeId = outputNodeId;
m_outputPortId = outputPortId;
}
public override void ExecuteForward()
{
UIUtils.DeleteConnection( true, m_oldInputNodeId, m_oldInputNodePortId, false, true );
UIUtils.ConnectInputToOutput( m_newInputNodeId, m_newInputNodePortId, m_outputNodeId, m_outputPortId );
}
public override void ExecuteReverse()
{
base.ExecuteReverse();
UIUtils.DeleteConnection( true, m_newInputNodeId, m_newInputNodePortId, false, true );
UIUtils.ConnectInputToOutput( m_oldInputNodeId, m_oldInputNodePortId, m_outputNodeId, m_outputPortId );
}
public override string ToString()
{
return "Move Input Connection Node - Old Input Node: " + m_oldInputNodeId + " Old Input Port: " + m_oldInputNodePortId + " New Input Node: " + m_newInputNodeId + " New Input Port: " + m_newInputNodePortId + " Output Node: " + m_outputNodeId + " Output Port: " + m_outputPortId;
}
}
public class MoveOutputConnectionActionData : ActionData
{
private int m_inputNodeId;
private int m_inputPortId;
private int m_newOutputNodeId;
private int m_newOutputPortId;
private int m_oldOutputNodeId;
private int m_oldOutputPortId;
public MoveOutputConnectionActionData( int inputNodeId, int inputPortId, int newOutputNodeId, int newOutputPortId, int oldOutputNodeId, int oldOutputPortId )
{
m_inputNodeId = inputNodeId;
m_inputPortId = inputPortId;
m_newOutputNodeId = newOutputNodeId;
m_newOutputPortId = newOutputPortId;
m_oldOutputNodeId = oldOutputNodeId;
m_oldOutputPortId = oldOutputPortId;
}
public override void ExecuteForward()
{
UIUtils.DeleteConnection( false, m_oldOutputNodeId, m_oldOutputNodeId, false, true );
UIUtils.ConnectInputToOutput( m_inputNodeId, m_inputPortId, m_newOutputNodeId, m_newOutputPortId );
}
public override void ExecuteReverse()
{
base.ExecuteReverse();
UIUtils.DeleteConnection( false, m_newOutputNodeId, m_newOutputPortId, false, true );
UIUtils.ConnectInputToOutput( m_inputNodeId, m_inputPortId, m_oldOutputNodeId, m_oldOutputPortId );
}
public override string ToString()
{
return "Move Input Connection Node - Input Node: " + m_inputNodeId + " Input Port: " + m_inputPortId + " Old Output Node: " + m_oldOutputNodeId + " Old Output Port: " + m_oldOutputPortId + " New Output Node: " + m_newOutputNodeId + " New Output Port: " + m_newOutputPortId;
}
}
public class CreateNewGraphActionData : ActionData
{
private string m_name;
public CreateNewGraphActionData( string name )
{
m_name = name;
}
public override void ExecuteForward()
{
UIUtils.CreateNewGraph( m_name );
}
}
public class ChangeNodePropertiesActionData : ActionData
{
private string m_originalProperties;
private string m_newProperties;
private int m_nodeId;
public ChangeNodePropertiesActionData( ParentNode node, string originalProperties )
{
m_nodeId = node.UniqueId;
m_originalProperties = originalProperties;
m_newProperties = string.Empty;
string trash = string.Empty;
node.WriteToString( ref m_newProperties, ref trash );
}
public ChangeNodePropertiesActionData( int nodeId, string originalProperties )
{
m_nodeId = nodeId;
m_originalProperties = originalProperties;
m_newProperties = string.Empty;
string trash = string.Empty;
UIUtils.GetNode( nodeId ).WriteToString( ref m_newProperties, ref trash );
}
public override void ExecuteForward()
{
string[] properties = m_newProperties.Split( IOUtils.FIELD_SEPARATOR );
UIUtils.GetNode( m_nodeId ).ReadFromString( ref properties );
}
public override void ExecuteReverse()
{
string[] properties = m_originalProperties.Split( IOUtils.FIELD_SEPARATOR );
UIUtils.GetNode( m_nodeId ).ReadFromString( ref properties );
}
public override string ToString()
{
return "Change Node Propertie - Node: " + m_nodeId + "\nOriginal Properties:\n" + m_originalProperties + "\nNew Properties:\n" + m_newProperties;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 29204f353101f46439a93f1c503d3197
timeCreated: 1481126954
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,58 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
public class ActionLog
{
private int m_maxCount;
private int m_index;
private List<ActionData> m_sequence;
public ActionLog(int maxCount)
{
m_maxCount = maxCount;
m_index = 0;
m_sequence = new List<ActionData>();
}
public void AddToLog(ActionData actionData)
{
if (m_sequence.Count > m_maxCount)
{
m_sequence.RemoveAt(0);
}
m_sequence.Add(actionData);
m_index = m_sequence.Count - 1;
}
public void UndoLastAction()
{
if ( m_index > -1 && m_index < m_sequence.Count )
m_sequence[m_index--].ExecuteReverse();
}
public void RedoLastAction()
{
if (m_index < (m_sequence.Count - 1))
m_sequence[++m_index].ExecuteForward();
}
public void ClearLog()
{
m_sequence.Clear();
m_index = 0;
}
public void Destroy()
{
m_sequence.Clear();
m_sequence = null;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bc089a69595d8994cb89946a919517c2
timeCreated: 1481126958
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,39 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
public class ActionSequence
{
private string m_name;
private List<ActionData> m_sequence;
public ActionSequence( string name )
{
m_name = name;
m_sequence = new List<ActionData>();
}
public void AddToSequence( ActionData actionData )
{
m_sequence.Add( actionData );
}
public void Execute()
{
for ( int i = 0; i < m_sequence.Count; i++ )
{
m_sequence[ i ].ExecuteForward();
}
}
public void Destroy()
{
m_sequence.Clear();
m_sequence = null;
}
public string Name { get { return m_name; } }
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 43bd963fa46ee9c4680dacff1d8dc0b9
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,690 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
public struct Constants
{
public readonly static string[] FaceMacros =
{
"#if defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) || defined(SHADER_API_D3D9)",
"#define FRONT_FACE_SEMANTIC VFACE",
"#define FRONT_FACE_TYPE float",
"#else",
"#define FRONT_FACE_SEMANTIC SV_IsFrontFace",
"#define FRONT_FACE_TYPE bool",
"#endif"
};
/*public readonly static string[] CustomASEStandardArgsMacros =
{
"#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC)//ASE Args Macros",
"#define ASE_TEXTURE2D_ARGS(textureName) Texture2D textureName, SamplerState sampler##textureName",
"#define ASE_TEXTURE3D_ARGS(textureName) Texture3D textureName, SamplerState sampler##textureName",
"#define ASE_TEXTURECUBE_ARGS(textureName) TextureCube textureName, SamplerState sampler##textureName",
"#define ASE_TEXTURE2D_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURE3D_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURECUBE_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURE2D_ARRAY_PARAMS(textureName) textureName, sampler##textureName",
"#else//ASE Args Macros",
"#define ASE_TEXTURE2D_ARGS(textureName) sampler2D textureName",
"#define ASE_TEXTURE3D_ARGS(textureName) sampler3D textureName",
"#define ASE_TEXTURECUBE_ARGS(textureName) samplerCUBE textureName",
"#define ASE_TEXTURE2D_PARAMS(textureName) textureName",
"#define ASE_TEXTURE3D_PARAMS(textureName) textureName",
"#define ASE_TEXTURECUBE_PARAMS(textureName) textureName",
"#define ASE_TEXTURE2D_ARRAY_PARAMS(textureName) textureName",
"#endif//ASE Args Macros\n"
};
public readonly static string[] CustomASEDeclararionMacros =
{
"#define ASE_TEXTURE2D(textureName) {0}2D(textureName)",
"#define ASE_TEXTURE2D_ARRAY(textureName) {0}2D_ARRAY(textureName)",
"#define ASE_TEXTURE3D(textureName) {0}3D(textureName)",
"#define ASE_TEXTURECUBE(textureName) {0}CUBE(textureName)\n"
};
public readonly static string[] CustomASEStandarSamplingMacrosHelper =
{
"#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC)//ASE Sampling Macros",
"#else//ASE Sampling Macros",
"#endif//ASE Sampling Macros\n"
};*/
/*public readonly static string[] CustomASESamplingMacros =
{
"#define ASE_SAMPLE_TEXTURE2D(textureName,{0}coords) {1}2D{2}(textureName,{0}coords)",
"#define ASE_SAMPLE_TEXTURE2D_LOD(textureName, {0}coord2, lod) {1}2D{2}_LOD(textureName, {0}coord2, lod)",
"#define ASE_SAMPLE_TEXTURE2D_BIAS(textureName,{0}coord2, bias) {1}2D{2}_BIAS(textureName,{0}coord2, bias)",
"#define ASE_SAMPLE_TEXTURE2D_GRAD(textureName,{0}coord2, dpdx, dpdy) {1}2D{2}_GRAD(textureName,{0}coord2, dpdx, dpdy)",
"#define ASE_SAMPLE_TEXTURE3D(textureName,{0}coord3) {1}3D{2}(textureName,{0}coord3)",
"#define ASE_SAMPLE_TEXTURE3D_LOD(textureName,{0}coord3, lod) {1}3D{2}_LOD(textureName,{0}coord3, lod)",
"#define ASE_SAMPLE_TEXTURE3D_BIAS(textureName,{0}coord3, bias) {1}3D{2}_BIAS(textureName,{0}coord3, bias)",
"#define ASE_SAMPLE_TEXTURE3D_GRAD(textureName,{0}coord3, dpdx, dpdy) {1}3D{2}_GRAD(textureName,{0}coord3, dpdx, dpdy)",
"#define ASE_SAMPLE_TEXTURECUBE(textureName,{0}coord3) {1}CUBE{2}(textureName,{0}coord3)",
"#define ASE_SAMPLE_TEXTURECUBE_LOD(textureName,{0}coord3, lod) {1}CUBE{2}_LOD(textureName,{0}coord3, lod)",
"#define ASE_SAMPLE_TEXTURECUBE_BIAS(textureName,{0}coord3, bias) {1}CUBE{2}_BIAS(textureName,{0}coord3, bias)\n"
};*/
// SRP
/*public readonly static string[] CustomASESRPArgsMacros =
{
"#define ASE_TEXTURE2D_ARGS(textureName) TEXTURE2D(textureName), SAMPLER(textureName)",
"#define ASE_TEXTURE3D_ARGS(textureName) TEXTURE3D(textureName), SAMPLER(textureName)",
"#define ASE_TEXTURECUBE_ARGS(textureName) TEXTURECUBE(textureName), SAMPLER(textureName)",
"#define ASE_TEXTURE2D_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURE3D_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURECUBE_PARAMS(textureName) textureName, sampler##textureName",
"#define ASE_TEXTURE2D_ARRAY_PARAMS(textureName) textureName, sampler##textureName\n"
};*/
public readonly static RenderTextureFormat PreviewFormat = RenderTextureFormat.ARGBFloat;
public readonly static int PreviewSize = 128;
public readonly static List<string> UnityNativeInspectors = new List<string>
{
"Rendering.HighDefinition.LightingShaderGraphGUI",
"Rendering.HighDefinition.HDUnlitGUI",
"UnityEditor.Rendering.HighDefinition.HDLitGUI",
"UnityEditor.ShaderGraph.PBRMasterGUI",
"UnityEditor.Rendering.HighDefinition.DecalGUI",
"UnityEditor.Rendering.HighDefinition.FabricGUI",
"UnityEditor.Experimental.Rendering.HDPipeline.HDLitGUI",
"Rendering.HighDefinition.DecalGUI",
"Rendering.HighDefinition.LitShaderGraphGUI",
"Rendering.HighDefinition.DecalShaderGraphGUI"
};
public readonly static Dictionary<string, string> CustomInspectorHD7To10 = new Dictionary<string, string>
{
{ "UnityEditor.Rendering.HighDefinition.DecalGUI","Rendering.HighDefinition.DecalGUI"},
{ "UnityEditor.Rendering.HighDefinition.FabricGUI","Rendering.HighDefinition.LightingShaderGraphGUI"},
{ "UnityEditor.Rendering.HighDefinition.HDLitGUI","Rendering.HighDefinition.LitShaderGraphGUI"},
{ "UnityEditor.Experimental.Rendering.HDPipeline.HDLitGUI","Rendering.HighDefinition.LitShaderGraphGUI"},
};
public readonly static Dictionary<string , string> CustomInspectorHDLegacyTo11 = new Dictionary<string , string>
{
{ "UnityEditor.Rendering.HighDefinition.DecalGUI","Rendering.HighDefinition.DecalShaderGraphGUI"},
{ "Rendering.HighDefinition.DecalGUI","Rendering.HighDefinition.DecalShaderGraphGUI"},
{ "UnityEditor.Rendering.HighDefinition.FabricGUI","Rendering.HighDefinition.LightingShaderGraphGUI"},
{ "UnityEditor.Rendering.HighDefinition.HDLitGUI","Rendering.HighDefinition.LitShaderGraphGUI"},
{ "UnityEditor.Experimental.Rendering.HDPipeline.HDLitGUI","Rendering.HighDefinition.LitShaderGraphGUI"},
};
public readonly static string CustomASEStandardSamplerParams = "#define ASE_TEXTURE_PARAMS(textureName) textureName\n";
public readonly static string[] CustomASESRPTextureArrayMacros =
{
"#define ASE_TEXTURE2D_ARRAY_ARGS(textureName) TEXTURE2D_ARRAY_ARGS(textureName,sampler##textureName)\n" ,
"#define ASE_TEXTURE2D_ARRAY_PARAM(textureName) TEXTURE2D_ARRAY_PARAM(textureName,sampler##textureName)\n" ,
"#define ASE_SAMPLE_TEXTURE2D_ARRAY(textureName, coord3) textureName.Sample(sampler##textureName, coord3)",
"#define ASE_SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, coord3, lod) textureName.SampleLevel(sampler##textureName, coord3, lod)"
};
public readonly static string CustomASESRPSamplerParams = "#define ASE_TEXTURE_PARAMS(textureName) textureName, sampler##textureName\n";
public readonly static string[] CustomSRPSamplingMacros =
{
"#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC) || defined(SHADER_API_PSSL) || (defined(SHADER_TARGET_SURFACE_ANALYSIS) && !defined(SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER))//3D SRP MACROS",
"#define SAMPLE_TEXTURE3D_GRAD(textureName, samplerName, coord3, dpdx, dpdy) textureName.SampleGrad(samplerName, coord3, dpdx, dpdy)",
"#define SAMPLE_TEXTURE3D_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)",
"#else//3D SRP MACROS",
"#define SAMPLE_TEXTURE3D_GRAD(textureName, samplerName, coord3, dpdx, dpdy) SAMPLE_TEXTURE3D(textureName, samplerName, coord3)",
"#define SAMPLE_TEXTURE3D_BIAS(textureName, samplerName, coord3, bias) SAMPLE_TEXTURE3D(textureName, samplerName, coord3)",
"#endif//3D SRP MACROS\n"
};
public readonly static Dictionary<TextureType, string> TexDeclarationSRPMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"TEXTURE2D({0}); SAMPLER(sampler{0});"},
{ TextureType.Texture3D,"TEXTURE3D({0}); SAMPLER(sampler{0});"},
{ TextureType.Cube,"TEXTURECUBE({0}); SAMPLER(sampler{0});"},
{ TextureType.Texture2DArray,"TEXTURE2D_ARRAY({0}); SAMPLER(sampler{0});"},
};
public readonly static Dictionary<TextureType, string> SamplerDeclarationSRPMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"SAMPLER(sampler{0});"},
{ TextureType.Texture3D,"SAMPLER(sampler{0});"},
{ TextureType.Cube,"SAMPLER(sampler{0});"},
{ TextureType.Texture2DArray,"SAMPLER(sampler{0});"},
};
public readonly static Dictionary<TextureType, string> TexDeclarationNoSamplerSRPMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"TEXTURE2D({0})"},
{ TextureType.Texture3D,"TEXTURE3D({0})"},
{ TextureType.Cube,"TEXTURECUBE({0})"},
{ TextureType.Texture2DArray,"TEXTURE2D_ARRAY({0})"},
};
public readonly static Dictionary<TextureType, string> TexSampleSRPMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"SAMPLE_TEXTURE2D{0}( {1}, {2}, {3} )"},
{ TextureType.Texture3D,"SAMPLE_TEXTURE3D{0}( {1}, {2}, {3} )"},
{ TextureType.Cube,"SAMPLE_TEXTURECUBE{0}( {1}, {2}, {3} )"},
{ TextureType.Texture2DArray,"SAMPLE_TEXTURE2D_ARRAY{0}( {1}, {2}, {3} )"},
};
public readonly static Dictionary<TextureType, string> TexParams = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"ASE_TEXTURE2D_PARAMS({0})"},
{ TextureType.Texture3D,"ASE_TEXTURE3D_PARAMS({0})"},
{ TextureType.Cube,"ASE_TEXTURECUBE_PARAMS({0})"},
{ TextureType.Texture2DArray,"ASE_TEXTURE2D_ARRAY_PARAMS({0})"},
};
public readonly static Dictionary<WirePortDataType, TextureType> WireToTexture = new Dictionary<WirePortDataType, TextureType>
{
{ WirePortDataType.SAMPLER1D,TextureType.Texture1D},
{ WirePortDataType.SAMPLER2D,TextureType.Texture2D},
{ WirePortDataType.SAMPLER3D,TextureType.Texture3D},
{ WirePortDataType.SAMPLERCUBE,TextureType.Cube},
{ WirePortDataType.SAMPLER2DARRAY,TextureType.Texture2DArray},
};
public readonly static Dictionary<TextureType, WirePortDataType> TextureToWire = new Dictionary<TextureType, WirePortDataType>
{
{ TextureType.Texture1D,WirePortDataType.SAMPLER1D},
{ TextureType.Texture2D,WirePortDataType.SAMPLER2D},
{ TextureType.Texture3D, WirePortDataType.SAMPLER3D},
{ TextureType.Cube,WirePortDataType.SAMPLERCUBE},
{ TextureType.Texture2DArray,WirePortDataType.SAMPLER2DARRAY},
{ TextureType.ProceduralTexture,WirePortDataType.SAMPLER2D},
};
public readonly static string SamplingMacrosDirective = "#define ASE_USING_SAMPLING_MACROS 1";
// STANDARD
public readonly static string[] CustomASEStandarSamplingMacrosHelper =
{
#if UNITY_2018_1_OR_NEWER
"#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC) || defined(SHADER_API_PSSL) || (defined(SHADER_TARGET_SURFACE_ANALYSIS) && !defined(SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER))//ASE Sampler Macros",
#else
"#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC) || defined(SHADER_API_PSSL)//ASE Sampler Macros",
#endif
"#else//ASE Sampling Macros",
"#endif//ASE Sampling Macros\n"
};
public readonly static string[] CustomASEArraySamplingMacrosRecent =
{
"#define UNITY_SAMPLE_TEX2DARRAY(tex,coord) tex.Sample(sampler##tex,coord)",
"#define UNITY_SAMPLE_TEX2DARRAY_LOD(tex,coord,lod) tex.SampleLevel(sampler##tex,coord, lod)",
"#define UNITY_SAMPLE_TEX2DARRAY_BIAS(tex,coord,bias) tex.SampleBias(sampler##tex,coord,bias)",
"#define UNITY_SAMPLE_TEX2DARRAY_GRAD(tex,coord,ddx,ddy) tex.SampleGrad(sampler##tex,coord,ddx,ddy)",
};
public readonly static string[] CustomASEArraySamplingMacrosOlder =
{
"#define UNITY_SAMPLE_TEX2DARRAY(tex,coord) tex2DArray(tex,coord)",
"#define UNITY_SAMPLE_TEX2DARRAY_LOD(tex,coord,lod) tex2DArraylod(tex, float4(coord,lod))",
"#define UNITY_SAMPLE_TEX2DARRAY_BIAS(tex,coord,bias) tex2DArray(tex,coord)",
"#define UNITY_SAMPLE_TEX2DARRAY_GRAD(tex,coord,ddx,ddy) tex2DArray(tex,coord)",
};
public readonly static string[] CustomASEStandarSamplingMacrosRecent =
{
"#define SAMPLE_TEXTURE2D(tex,samplerTex,coord) tex.Sample(samplerTex,coord)",
"#define SAMPLE_TEXTURE2D_LOD(tex,samplerTex,coord,lod) tex.SampleLevel(samplerTex,coord, lod)",
"#define SAMPLE_TEXTURE2D_BIAS(tex,samplerTex,coord,bias) tex.SampleBias(samplerTex,coord,bias)",
"#define SAMPLE_TEXTURE2D_GRAD(tex,samplerTex,coord,ddx,ddy) tex.SampleGrad(samplerTex,coord,ddx,ddy)",
"#define SAMPLE_TEXTURE3D(tex,samplerTex,coord) tex.Sample(samplerTex,coord)",
"#define SAMPLE_TEXTURE3D_LOD(tex,samplerTex,coord,lod) tex.SampleLevel(samplerTex,coord, lod)",
"#define SAMPLE_TEXTURE3D_BIAS(tex,samplerTex,coord,bias) tex.SampleBias(samplerTex,coord,bias)",
"#define SAMPLE_TEXTURE3D_GRAD(tex,samplerTex,coord,ddx,ddy) tex.SampleGrad(samplerTex,coord,ddx,ddy)",
"#define SAMPLE_TEXTURECUBE(tex,samplerTex,coord) tex.Sample(samplerTex,coord)",
"#define SAMPLE_TEXTURECUBE_LOD(tex,samplerTex,coord,lod) tex.SampleLevel(samplerTex,coord, lod)",
"#define SAMPLE_TEXTURECUBE_BIAS(tex,samplerTex,coord,bias) tex.SampleBias(samplerTex,coord,bias)",
"#define SAMPLE_TEXTURECUBE_GRAD(tex,samplerTex,coord,ddx,ddy) tex.SampleGrad(samplerTex,coord,ddx,ddy)",
"#define SAMPLE_TEXTURE2D_ARRAY(tex,samplerTex,coord) tex.Sample(samplerTex,coord)",
"#define SAMPLE_TEXTURE2D_ARRAY_LOD(tex,samplerTex,coord,lod) tex.SampleLevel(samplerTex,coord, lod)",
"#define SAMPLE_TEXTURE2D_ARRAY_BIAS(tex,samplerTex,coord,bias) tex.SampleBias(samplerTex,coord,bias)",
"#define SAMPLE_TEXTURE2D_ARRAY_GRAD(tex,samplerTex,coord,ddx,ddy) tex.SampleGrad(samplerTex,coord,ddx,ddy)",
};
public readonly static string[] CustomASEStandarSamplingMacrosOlder =
{
"#define SAMPLE_TEXTURE2D(tex,samplerTex,coord) tex2D(tex,coord)",
"#define SAMPLE_TEXTURE2D_LOD(tex,samplerTex,coord,lod) tex2Dlod(tex,float4(coord,0,lod))",
"#define SAMPLE_TEXTURE2D_BIAS(tex,samplerTex,coord,bias) tex2Dbias(tex,float4(coord,0,bias))",
"#define SAMPLE_TEXTURE2D_GRAD(tex,samplerTex,coord,ddx,ddy) tex2Dgrad(tex,coord,ddx,ddy)",
"#define SAMPLE_TEXTURE3D(tex,samplerTex,coord) tex3D(tex,coord)",
"#define SAMPLE_TEXTURE3D_LOD(tex,samplerTex,coord,lod) tex3Dlod(tex,float4(coord,lod))",
"#define SAMPLE_TEXTURE3D_BIAS(tex,samplerTex,coord,bias) tex3D(tex,coord)",
"#define SAMPLE_TEXTURE3D_GRAD(tex,samplerTex,coord,ddx,ddy) tex3D(tex,coord)",
"#define SAMPLE_TEXTURECUBE(tex,samplertex,coord) texCUBE(tex,coord)",
"#define SAMPLE_TEXTURECUBE_LOD(tex,samplertex,coord,lod) texCUBElod (tex,half4(coord,lod))",
"#define SAMPLE_TEXTURECUBE_BIAS(tex,samplertex,coord,bias) texCUBE(tex,coord)",
"#define SAMPLE_TEXTURECUBE_GRAD(tex,samplertex,coord,ddx,ddy) texCUBE(tex,coord)",
"#define SAMPLE_TEXTURE2D_ARRAY(tex,samplertex,coord) tex2DArray(tex,coord)",
"#define SAMPLE_TEXTURE2D_ARRAY_LOD(tex,samplertex,coord,lod) tex2DArraylod(tex, float4(coord,lod))",
"#define SAMPLE_TEXTURE2D_ARRAY_BIAS(tex,samplerTex,coord,bias) tex2DArray(tex,coord)",
"#define SAMPLE_TEXTURE2D_ARRAY_GRAD(tex,samplerTex,coord,ddx,ddy) tex2DArray(tex,coord)",
};
public readonly static string[] CustomArraySamplingMacros =
{
"#if defined(UNITY_COMPILER_HLSL2GLSL) || defined(SHADER_TARGET_SURFACE_ANALYSIS)//ASE Array Sampler Macros",
"#define ASE_SAMPLE_TEX2DARRAY_GRAD(tex,coord,dx,dy) UNITY_SAMPLE_TEX2DARRAY (tex,coord)",
"#else//ASE Array Sampler Macros",
"#define ASE_SAMPLE_TEX2DARRAY_GRAD(tex,coord,dx,dy) tex.SampleGrad (sampler##tex,coord,dx,dy)",
"#endif//ASE Array Sampler Macros\n"
};
public readonly static Dictionary<TextureType, string> TexDeclarationStandardMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"UNITY_DECLARE_TEX2D({0});"},
{ TextureType.Texture3D,"UNITY_DECLARE_TEX3D({0});"},
{ TextureType.Cube,"UNITY_DECLARE_TEXCUBE({0});"},
{ TextureType.Texture2DArray,"UNITY_DECLARE_TEX2DARRAY({0});"}
};
public readonly static Dictionary<TextureType, string> TexDeclarationNoSamplerStandardMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"UNITY_DECLARE_TEX2D_NOSAMPLER({0})"},
{ TextureType.Texture3D,"UNITY_DECLARE_TEX3D_NOSAMPLER({0})"},
{ TextureType.Cube,"UNITY_DECLARE_TEXCUBE_NOSAMPLER({0})"},
{ TextureType.Texture2DArray,"UNITY_DECLARE_TEX2DARRAY_NOSAMPLER({0})"}
};
public readonly static Dictionary<TextureType, string> TexSampleStandardMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"UNITY_SAMPLE_TEX2D{0}( {1}, {3} )"},
{ TextureType.Texture3D,"UNITY_SAMPLE_TEX3D{0}( {1}, {3} )"},
{ TextureType.Cube,"UNITY_SAMPLE_TEXCUBE{0}( {1}, {3} )"},
{ TextureType.Texture2DArray,"UNITY_SAMPLE_TEX2DARRAY{0}( {1}, {3} )"}
};
public readonly static Dictionary<TextureType, string> TexSampleSamplerStandardMacros = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"SAMPLE_TEXTURE2D{0}( {1}, {2}, {3} )"},
{ TextureType.Texture3D,"SAMPLE_TEXTURE3D{0}( {1}, {2}, {3} )"},
{ TextureType.Cube,"SAMPLE_TEXTURECUBE{0}( {1}, {2}, {3} )"},
{ TextureType.Texture2DArray,"SAMPLE_TEXTURE2D_ARRAY{0}( {1}, {2}, {3} )"}
};
public readonly static Dictionary<TextureType, string> TexSampleStandard = new Dictionary<TextureType, string>
{
{ TextureType.Texture2D,"tex2D{0}( {1}, {2} )"},
{ TextureType.Texture3D,"tex3D{0}( {1}, {2} )"},
{ TextureType.Cube,"texCUBE{0}( {1}, {2} )"},
{ TextureType.Texture2DArray,"tex2DArray{0}( {1}, {2} )"}
};
public readonly static char LineFeedSeparator = '$';
public readonly static char SemiColonSeparator = '@';
public readonly static string AppDataFullName = "appdata_full";
public readonly static string CustomAppDataFullName = "appdata_full_custom";
public readonly static string CustomAppDataFullBody =
"\n\t\tstruct appdata_full_custom\n" +
"\t\t{\n" +
"\t\t\tfloat4 vertex : POSITION;\n" +
"\t\t\tfloat4 tangent : TANGENT;\n" +
"\t\t\tfloat3 normal : NORMAL;\n" +
"\t\t\tfloat4 texcoord : TEXCOORD0;\n" +
"\t\t\tfloat4 texcoord1 : TEXCOORD1;\n" +
"\t\t\tfloat4 texcoord2 : TEXCOORD2;\n" +
"\t\t\tfloat4 texcoord3 : TEXCOORD3;\n" +
"\t\t\tfloat4 color : COLOR;\n" +
"\t\t\tUNITY_VERTEX_INPUT_INSTANCE_ID\n";
public readonly static string IncludeFormat = "#include \"{0}\"";
public readonly static string PragmaFormat = "#pragma {0}";
public readonly static string DefineFormat = "#define {0}";
public readonly static string RenderTypeHelperStr = "RenderType";
public readonly static string RenderQueueHelperStr = "Queue";
public readonly static string DisableBatchingHelperStr = "DisableBatching";
public readonly static string DefaultShaderName = "New Amplify Shader";
public readonly static string UndoReplaceMasterNodeId = "Replacing Master Node";
public readonly static string UnityLightingLib = "Lighting.cginc";
public readonly static string UnityAutoLightLib = "AutoLight.cginc";
public readonly static string UnityBRDFLib = "UnityStandardBRDF.cginc";
public readonly static string LocalValueDecWithoutIdent = "{0} {1} = {2};";
public readonly static string CustomTypeLocalValueDecWithoutIdent = "{0} {1} =({0}){2};";
public readonly static string LocalValueDefWithoutIdent = "{0} {1} {2};";
public readonly static string TilingOffsetFormat = "{0} * {1} + {2}";
public static string InvalidPostProcessDatapath = "__DELETED_GUID_Trash";
//TEMPLATES
public static float PlusMinusButtonLayoutWidth = 15;
public static float NodeButtonSizeX = 16;
public static float NodeButtonSizeY = 16;
public static float NodeButtonDeltaX = 5;
public static float NodeButtonDeltaY = 11;
public readonly static string SafeNormalizeInfoStr = "With Safe Normalize division by 0 is prevented over the normalize operation at the expense of additional instructions on shader.";
public readonly static string ReservedPropertyNameStr = "Property name '{0}' is reserved and cannot be used";
public readonly static string NumericPropertyNameStr = "Property name '{0}' is numeric thus cannot be used";
public readonly static string DeprecatedMessageStr = "Node '{0}' is deprecated. Use node '{1}' instead.";
public readonly static string DeprecatedNoAlternativeMessageStr = "Node '{0}' is deprecated and should be removed.";
public readonly static string UndoChangePropertyTypeNodesId = "Changing Property Types";
public readonly static string UndoChangeTypeNodesId = "Changing Nodes Types";
public readonly static string UndoMoveNodesId = "Moving Nodes";
public readonly static string UndoRegisterFullGrapId = "Register Graph";
public readonly static string UndoAddNodeToCommentaryId = "Add node to Commentary";
public readonly static string UndoRemoveNodeFromCommentaryId = "Remove node from Commentary";
public readonly static string UndoCreateDynamicPortId = "Create Dynamic Port";
public readonly static string UndoDeleteDynamicPortId = "Destroy Dynamic Port";
public readonly static string UndoRegisterNodeId = "Register Object";
public readonly static string UndoUnregisterNodeId = "Unregister Object";
public readonly static string UndoCreateNodeId = "Create Object";
public readonly static string UndoPasteNodeId = "Paste Object";
public readonly static string UndoDeleteNodeId = "Destroy Object";
public readonly static string UndoDeleteConnectionId = "Destroy Connection";
public readonly static string UndoCreateConnectionId = "Create Connection";
public readonly static float MenuDragSpeed = -0.5f;
public readonly static string DefaultCustomInspector = "ASEMaterialInspector";
public readonly static string ReferenceTypeStr = "Mode";
public readonly static string AvailableReferenceStr = "Reference";
public readonly static string InstancePostfixStr = " (Reference) ";
public readonly static string ASEMenuName = "Amplify Shader";
public readonly static string LodCrossFadeOption2017 = "dithercrossfade";
public readonly static string UnityShaderVariables = "UnityShaderVariables.cginc";
public readonly static string UnityCgLibFuncs = "UnityCG.cginc";
public readonly static string UnityStandardUtilsLibFuncs = "UnityStandardUtils.cginc";
public readonly static string UnityPBSLightingLib = "UnityPBSLighting.cginc";
public readonly static string UnityDeferredLightLib = "UnityDeferredLibrary.cginc";
public readonly static string ATSharedLibGUID = "ba242738c4be3324aa88d126f7cc19f9";
#if UNITY_5_6_OR_NEWER
public readonly static string CameraDepthTextureValue = "UNITY_DECLARE_DEPTH_TEXTURE( _CameraDepthTexture );";
#else
public readonly static string CameraDepthTextureValue = "uniform sampler2D _CameraDepthTexture;";
#endif
//public readonly static string CameraDepthTextureSRPVar = "TEXTURE2D(_CameraDepthTexture);";
//public readonly static string CameraDepthTextureSRPSampler = "SAMPLER(sampler_CameraDepthTexture);";
public readonly static string CameraDepthTextureLWEnabler = "REQUIRE_DEPTH_TEXTURE 1";
public readonly static string CameraDepthTextureTexelSize = "uniform float4 _CameraDepthTexture_TexelSize;";
public readonly static string InstanceIdMacro = "UNITY_VERTEX_INPUT_INSTANCE_ID";
public readonly static string InstanceIdVariable = "UNITY_GET_INSTANCE_ID({0})";
public readonly static string HelpURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor";
//public readonly static string NodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Nodes#";
//public readonly static string CommunityNodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Community_Nodes#";
public readonly static string NodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/";
public readonly static string CommunityNodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/";
public readonly static Color InfiniteLoopColor = Color.red;
public readonly static Color DefaultCategoryColor = new Color( 0.26f, 0.35f, 0.44f, 1.0f );
public readonly static Color NodeBodyColor = new Color( 1f, 1f, 1f, 1.0f );
public readonly static Color ModeTextColor = new Color( 1f, 1f, 1f, 0.25f );
public readonly static Color ModeIconColor = new Color( 1f, 1f, 1f, 0.75f );
public readonly static Color PortTextColor = new Color( 1f, 1f, 1f, 0.5f );
public readonly static Color PortLockedTextColor = new Color( 1f, 1f, 1f, 0.35f );
public readonly static Color BoxSelectionColor = new Color( 0.5f, 0.75f, 1f, 0.33f );
public readonly static Color SpecialRegisterLocalVarSelectionColor = new Color( 0.27f, 0.52f, 1.0f, 1f );
public readonly static Color SpecialGetLocalVarSelectionColor = new Color( 0.2f, 0.8f, 0.4f, 1f );
public readonly static Color NodeSelectedColor = new Color( 0.85f, 0.56f, 0f, 1f );
public readonly static Color NodeDefaultColor = new Color( 1f, 1f, 1f, 1f );
public readonly static Color NodeConnectedColor = new Color( 1.0f, 1f, 0.0f, 1f );
public readonly static Color NodeErrorColor = new Color( 1f, 0.5f, 0.5f, 1f );
public readonly static string NoSpecifiedCategoryStr = "<None>";
public readonly static int MINIMIZE_WINDOW_LOCK_SIZE = 630;
public readonly static int FoldoutMouseId = 0; // Left Mouse Button
public readonly static float SNAP_SQR_DIST = 200f;
public readonly static int INVALID_NODE_ID = -1;
public readonly static float WIRE_WIDTH = 7f;
public readonly static float WIRE_CONTROL_POINT_DIST = 0.7f;
public readonly static float WIRE_CONTROL_POINT_DIST_INV = 1.7f;
public readonly static float IconsLeftRightMargin = 5f;
public readonly static float PropertyPickerWidth = 16f;
public readonly static float PropertyPickerHeight = 16f;
public readonly static float PreviewExpanderWidth = 16f;
public readonly static float PreviewExpanderHeight = 16f;
public readonly static float TextFieldFontSize = 11f;
public readonly static float DefaultFontSize = 15f;
public readonly static float DefaultTitleFontSize = 13f;
public readonly static float PropertiesTitleFontSize = 11f;
public readonly static float MessageFontSize = 40f;
public readonly static float SelectedObjectFontSize = 30f;
public readonly static float PORT_X_ADJUST = 10;
public readonly static float PORT_INITIAL_X = 10;
public readonly static float PORT_INITIAL_Y = 40;
public readonly static float INPUT_PORT_DELTA_Y = 5;
public readonly static float PORT_TO_LABEL_SPACE_X = 5;
public readonly static float NODE_HEADER_HEIGHT = 32;
public readonly static float NODE_HEADER_EXTRA_HEIGHT = 5;
public readonly static float NODE_HEADER_LEFTRIGHT_MARGIN = 10;
public readonly static float MULTIPLE_SELECION_BOX_ALPHA = 0.5f;
public readonly static float RMB_CLICK_DELTA_TIME = 0.1f;
public readonly static float RMB_SCREEN_DIST = 10f;
public readonly static float CAMERA_MAX_ZOOM = 2f;
public readonly static float CAMERA_MIN_ZOOM = 1f;
public readonly static float CAMERA_ZOOM_SPEED = 0.1f;
public readonly static float ALT_CAMERA_ZOOM_SPEED = -0.05f;
public readonly static object INVALID_VALUE = null;
public readonly static float HORIZONTAL_TANGENT_SIZE = 100f;
public readonly static float OUTSIDE_WIRE_MARGIN = 5f;
public readonly static string SubTitleNameFormatStr = "Name( {0} )";
public readonly static string SubTitleSpaceFormatStr = "Space( {0} )";
public readonly static string SubTitleTypeFormatStr = "Type( {0} )";
public readonly static string SubTitleValueFormatStr = "Value( {0} )";
public readonly static string SubTitleConstFormatStr = "Const( {0} )";
public readonly static string SubTitleVarNameFormatStr = "Var( {0} )";
public readonly static string SubTitleRefNameFormatStr = "Ref( {0} )";
public readonly static string CodeWrapper = "( {0} )";
public readonly static string InlineCodeWrapper = "{{\n{0}\n}}";
public readonly static string NodesDumpFormat = "{0}:,{1},{2}\n";
public readonly static string TagFormat = " \"{0}\" = \"{1}\"";
public readonly static string LocalVarIdentation = "\t\t\t";
public readonly static string SimpleLocalValueDec = LocalVarIdentation + "{0} {1};\n";
public readonly static string LocalValueDec = LocalVarIdentation + LocalValueDecWithoutIdent + '\n';
public readonly static string LocalValueDef = LocalVarIdentation + "{0} = {1};\n";
public readonly static string CastHelper = "({0}).{1}";
public readonly static string PropertyLocalVarDec = "{0} {1} = {0}({2});";
public readonly static string[] UniformDec = { "uniform {0} {1};", "{0} {1};" };
public readonly static string PropertyValueLabel = "Value( {0} )";
public readonly static string ConstantsValueLabel = "Const( {0} )";
public readonly static string PropertyFloatFormatLabel = "0.###";
public readonly static string PropertyBigFloatFormatLabel = "0.###e+0";
public readonly static string PropertyIntFormatLabel = "0";
public readonly static string PropertyBigIntFormatLabel = "0e+0";
public readonly static string PropertyVectorFormatLabel = "0.##";
public readonly static string PropertyBigVectorFormatLabel = "0.##e+0";
public readonly static string PropertyMatrixFormatLabel = "0.#";
public readonly static string PropertyBigMatrixFormatLabel = "0.#e+0";
public readonly static string NoPropertiesLabel = "No assigned properties";
public readonly static string ValueLabel = "Value";
public readonly static string DefaultValueLabel = "Default Value";
public readonly static string MaterialValueLabel = "Material Value";
public readonly static GUIContent DefaultValueLabelContent = new GUIContent( "Default Value" );
public readonly static GUIContent MaterialValueLabelContent = new GUIContent( "Material Value" );
public readonly static string InputVarStr = "i";//"input";
public readonly static string OutputVarStr = "o";//"output";
public readonly static string CustomLightOutputVarStr = "s";
public readonly static string CustomLightStructStr = "Custom";
public readonly static string VertexShaderOutputStr = "o";
public readonly static string VertexShaderInputStr = "v";//"vertexData";
public readonly static string VertexDataFunc = "vertexDataFunc";
public readonly static string VirtualCoordNameStr = "vcoord";
public readonly static string VertexVecNameStr = "vertexVec";
public readonly static string VertexVecDecStr = "float3 " + VertexVecNameStr;
public readonly static string VertexVecVertStr = VertexShaderOutputStr + "." + VertexVecNameStr;
public readonly static string NormalVecNameStr = "normalVec";
public readonly static string NormalVecDecStr = "float3 " + NormalVecNameStr;
public readonly static string NormalVecFragStr = InputVarStr + "." + NormalVecNameStr;
public readonly static string NormalVecVertStr = VertexShaderOutputStr + "." + NormalVecNameStr;
public readonly static string IncidentVecNameStr = "incidentVec";
public readonly static string IncidentVecDecStr = "float3 " + IncidentVecNameStr;
public readonly static string IncidentVecDefStr = VertexShaderOutputStr + "." + IncidentVecNameStr + " = normalize( " + VertexVecNameStr + " - _WorldSpaceCameraPos.xyz)";
public readonly static string IncidentVecFragStr = InputVarStr + "." + IncidentVecNameStr;
public readonly static string IncidentVecVertStr = VertexShaderOutputStr + "." + IncidentVecNameStr;
public readonly static string WorldNormalLocalDecStr = "WorldNormalVector( " + Constants.InputVarStr + " , {0}( 0,0,1 ))";
public readonly static string VFaceVariable = "ASEVFace";
public readonly static string VFaceInput = "half ASEVFace : VFACE";
public readonly static string ColorVariable = "vertexColor";
public readonly static string ColorInput = "float4 vertexColor : COLOR";
public readonly static string NoStringValue = "None";
public readonly static string EmptyPortValue = " ";
public readonly static string[] OverallInvalidChars = { "\r", "\n", "\\", " ", ".", ">", ",", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-" };
public readonly static string[] ShaderInvalidChars = { "\r", "\n", "\\", "\'", "\"", };
public readonly static string[] EnumInvalidChars = { "\r", "\n", "\\", ".", ">", ",", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-" };
public readonly static string[] AttrInvalidChars = { "\r", "\n", "\\", ">", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*" };
public readonly static string[] HeaderInvalidChars = { "\r", "\n", "\\", ">", ",", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-" };
public readonly static string[] WikiInvalidChars = { "#", "<", ">", "[", "]", "|", "{", "}", "%", "+", "?", "\\", "/", ",", ";", "." };
public readonly static string[,] UrlReplacementStringValues =
{
{ " = ", "Equals" },
{ " == ", "Equals" },
{ " != ", "NotEqual" },
{ " \u2260 ", "NotEqual" },
{ " > ", "Greater" },
{ " \u2265 " , "GreaterOrEqual" },
{ " >= ", "GreaterOrEqual" },
{ " < ", "Less" },
{ " \u2264 ", "LessOrEqual" },
{ " <= ", "LessOrEqual" },
{ " ", "_" },
{ "[", string.Empty },
{ "]", string.Empty }
};
public readonly static int UrlReplacementStringValuesLen = UrlReplacementStringValues.Length / 2;
public readonly static string[,] ReplacementStringValues =
{
{ " = ", "Equals" },
{ " == ", "Equals" },
{ " != ", "NotEqual" },
{ " \u2260 ", "NotEqual" },
{ " > ", "Greater" },
{ " \u2265 ", "GreaterOrEqual" },
{ " >= ", "GreaterOrEqual" },
{ " < ", "Less" },
{ " \u2264 ", "LessOrEqual" },
{ " <= ", "LessOrEqual" }
};
public readonly static int ReplacementStringValuesLen = ReplacementStringValues.Length / 2;
public readonly static string InternalData = "INTERNAL_DATA";
public readonly static string NoMaterialStr = "None";
public readonly static string OptionalParametersSep = " ";
public readonly static string NodeUndoId = "NODE_UNDO_ID";
public readonly static string NodeCreateUndoId = "NODE_CREATE_UNDO_ID";
public readonly static string NodeDestroyUndoId = "NODE_DESTROY_UNDO_ID";
// Custom node tags
//[InPortBegin:Id:Type:Name:InPortEnd]
public readonly static string CNIP = "#IP";
public readonly static float FLOAT_DRAW_HEIGHT_FIELD_SIZE = 16f;
public readonly static float FLOAT_DRAW_WIDTH_FIELD_SIZE = 45f;
public readonly static float FLOAT_WIDTH_SPACING = 3f;
public readonly static Color LockedPortColor = new Color( 0.3f, 0.3f, 0.3f, 0.5f );
#if UNITY_2018_2_OR_NEWER
public readonly static int[] AvailableUVChannels = { 0, 1, 2, 3, 4, 5, 6, 7 };
public readonly static string[] AvailableUVChannelsStr = { "0", "1", "2", "3", "4", "5", "6", "7"};
public readonly static string AvailableUVChannelLabel = "UV Channel";
public readonly static int[] AvailableUVSets = { 0, 1, 2, 3, 4, 5, 6, 7 };
public readonly static string[] AvailableUVSetsStr = { "1", "2", "3", "4","5", "6", "7", "8" };
public readonly static string AvailableUVSetsLabel = "UV Set";
#else
public readonly static int[] AvailableUVChannels = { 0, 1, 2, 3 };
public readonly static string[] AvailableUVChannelsStr = { "0", "1", "2", "3" };
public readonly static string AvailableUVChannelLabel = "UV Channel";
public readonly static int[] AvailableUVSets = { 0, 1, 2, 3 };
public readonly static string[] AvailableUVSetsStr = { "1", "2", "3", "4" };
public readonly static string AvailableUVSetsLabel = "UV Set";
#endif
public readonly static int[] AvailableUVSizes = { 2, 3, 4 };
public readonly static string[] AvailableUVSizesStr = { "Float 2", "Float 3", "Float 4" };
public readonly static string AvailableUVSizesLabel = "Coord Size";
public readonly static string LineSeparator = "________________________________";
public readonly static Vector2 CopyPasteDeltaPos = new Vector2( 40, 40 );
public readonly static string[] VectorSuffixes = { ".x", ".y", ".z", ".w" };
public readonly static string[] ColorSuffixes = { ".r", ".g", ".b", ".a" };
public const string InternalDataLabelStr = "Internal Data";
public const string AttributesLaberStr = "Attributes";
public const string ParameterLabelStr = "Parameters";
public static readonly string[] ReferenceArrayLabels = { "Object", "Reference" };
public static readonly string[] ChannelNamesVector = { "X", "Y", "Z", "W" };
public static readonly string[] ChannelNamesColor = { "R", "G", "B", "A" };
public static readonly string SamplerFormat = "sampler{0}";
public static readonly string SamplerDeclFormat = "SamplerState {0}";
public static readonly string SamplerDeclSRPFormat = "SAMPLER({0})";
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d833dd0968f913f449477da6bcd56b48
timeCreated: 1481126959
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2206c4bd7f3d18643a6a3452b0c070d1
folderAsset: yes
timeCreated: 1522769470
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,32 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
using AmplifyShaderEditor;
public class ASEBeginDecorator : MaterialPropertyDrawer
{
const int Separator = 2;
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
Rect button = position;
button.height = EditorGUIUtility.singleLineHeight;
if( GUI.Button( button, "Open in Shader Editor" ) )
{
Material mat = editor.target as Material;
#if UNITY_2018_3_OR_NEWER
ASEPackageManagerHelper.SetupLateMaterial( mat );
#else
AmplifyShaderEditorWindow.LoadMaterialToASE( mat );
#endif
}
}
public override float GetPropertyHeight( MaterialProperty prop, string label, MaterialEditor editor )
{
return EditorGUIUtility.singleLineHeight + Separator;
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: b766d08851589514b97afb23c6f30a70
guid: 508788a7fa76e1d42ad5fdfb1c941ed2
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,36 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
using AmplifyShaderEditor;
public class ASEEndDecorator : MaterialPropertyDrawer
{
bool m_applyNext = false;
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
if( prop.applyPropertyCallback == null )
prop.applyPropertyCallback = Testc;
if( GUI.changed || m_applyNext )
{
m_applyNext = false;
Material mat = editor.target as Material;
UIUtils.CopyValuesFromMaterial( mat );
}
}
bool Testc( MaterialProperty prop, int changeMask, object previousValue )
{
m_applyNext = true;
return false;
}
public override float GetPropertyHeight( MaterialProperty prop, string label, MaterialEditor editor )
{
return 0;
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: dae9aa560b4242648a3affa2bfabc365
guid: fdf2e52babbbbf040b3b9f6df50243f3
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,294 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
//
// Donated by BinaryCats
// https://forum.unity.com/threads/best-tool-asset-store-award-amplify-shader-editor-node-based-shader-creation-tool.430959/page-60#post-3414465
//////////////////////
// README / HOW TO USE
//////////////////////
// Examples:
//
// Floats:
//
// x Equals value
// EditableIf( _float1, Equalto, 1)
// This will allow the value to be edited, if the property _float1 is equal to 1. (_float1==1)
// Note: NotEqualTo is also a valid argument which will do the opposite of this example.EditableIf(_float1, NotEqualTo, 1) (NotEqualTo != 1)
//
// x Greater than value
// EditableIf(_Float1,GreaterThan,1)
// This will allow the value to be edited if the property _float1 is Greater than 1. (_float1>1)
//
// x Greater Than Or Equal to value
// EditableIf(_Float1,GreaterThanOrEqualTo,1)
// This will allow the value to be edited if the property _float1 is Greater than or equal to 1. (_float1>=1)
//
//
// x Less Than value
// EditableIf(_Float1,LessThan,1)
// This will allow the value to be edited if the property _float1 is Less than 1. (_float1<1)
//
// x Less Than Or Equal to value
// EditableIf(_Float1,LessThanOrEqualTo,1)
// This will allow the value to be edited if the property _float1 is Less than or equal to 1. (_float1<=1)
//
//
// Colour:
//
// x Equals r,g,b,a
// EditableIf(_Color0,EqualTo,255,255,255,255)
// This will allow the value to be edited, if the property _Color0 R,G,B and A value all Equal 255. (_Color0.R==255 && _Color0.G==255 & _Color0.B == 255 && _Color0.A == 255)
//
// x Equals alpha
// EditableIf(_Color0,EqualTo,null,null,null,255)
// This will allow the value to be edited, if the property _Color0 Alpha value is Equal to 255. (_Color0.A == 255)
//
// a Greater than blue
// EditableIf(_Color0,GreaterThan,null,null,125)
// This will allow the value to be edited, if the property _Color0 Blue value is Greater Than 125. (_Color0.B > 125)
// Note: as I do not want to check the Red or Green Values, i have entered "null" for the parameter
// Note: I have not inputted a value to check for Alpha, as i do not want to check it. Simularly, if I wanted to Only check the Red Value I could have used EditableIf(_Color0,GreaterThan,125)
//
// Like wise with floats GreaterThanOrEqualTo, LessThan, LessThanOrEqualTo
//
// Vector:
// Vector Checks work the same as colour checks
//
// Texture:
// x Does Not have a Texture
// EditableIf(_TextureSample0,Equals,null)
// This will allow the value to be edited, if the property _TextureSample0 does NOT have a texture
//
// x Does have a Texture
// EditableIf(_TextureSample0,NotEqualTo,null)
// This will allow the value to be edited, if the property _TextureSample0 does have a texture
using UnityEngine;
using UnityEditor;
using System;
public enum ComparisonOperators
{
EqualTo, NotEqualTo, GreaterThan, LessThan, EqualsOrGreaterThan, EqualsOrLessThan, ContainsFlags,
DoesNotContainsFlags
}
public class EditableIf : MaterialPropertyDrawer
{
ComparisonOperators op;
string FieldName = "";
object ExpectedValue;
bool InputError;
public EditableIf()
{
InputError = true;
}
public EditableIf( object fieldname, object comparison, object expectedvalue )
{
if( expectedvalue.ToString().ToLower() == "true" )
{
expectedvalue = (System.Single)1;
}
else if( expectedvalue.ToString().ToLower() == "false" )
{
expectedvalue = (System.Single)0;
}
Init( fieldname, comparison, expectedvalue );
}
public EditableIf( object fieldname, object comparison, object expectedvaluex, object expectedvaluey )
{
float? x = expectedvaluex as float?;
float? y = expectedvaluey as float?;
float? z = float.NegativeInfinity;
float? w = float.NegativeInfinity;
x = GetVectorValue( x );
y = GetVectorValue( y );
Init( fieldname, comparison, new Vector4( x.Value, y.Value, z.Value, w.Value ) );
}
public EditableIf( object fieldname, object comparison, object expectedvaluex, object expectedvaluey, object expectedvaluez )
{
float? x = expectedvaluex as float?;
float? y = expectedvaluey as float?;
float? z = expectedvaluez as float?;
float? w = float.NegativeInfinity;
x = GetVectorValue( x );
y = GetVectorValue( y );
z = GetVectorValue( z );
Init( fieldname, comparison, new Vector4( x.Value, y.Value, z.Value, w.Value ) );
}
public EditableIf( object fieldname, object comparison, object expectedvaluex, object expectedvaluey, object expectedvaluez, object expectedvaluew )
{
var x = expectedvaluex as float?;
var y = expectedvaluey as float?;
var z = expectedvaluez as float?;
var w = expectedvaluew as float?;
x = GetVectorValue( x );
y = GetVectorValue( y );
z = GetVectorValue( z );
w = GetVectorValue( w );
Init( fieldname, comparison, new Vector4( x.Value, y.Value, z.Value, w.Value ) );
}
private void Init( object fieldname, object comparison, object expectedvalue )
{
FieldName = fieldname.ToString();
var names = Enum.GetNames( typeof( ComparisonOperators ) );
var name = comparison.ToString().ToLower().Replace( " ", "" );
for( int i = 0; i < names.Length; i++ )
{
if( names[ i ].ToLower() == name )
{
op = (ComparisonOperators)i;
break;
}
}
ExpectedValue = expectedvalue;
}
private static float? GetVectorValue( float? x )
{
if( x.HasValue == false )
{
x = float.NegativeInfinity;
}
return x;
}
// Draw the property inside the given rect
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
if( InputError )
{
EditorGUI.LabelField( position, "EditableIf Attribute Error: Input parameters are invalid!" );
return;
}
var LHSprop = MaterialEditor.GetMaterialProperty( prop.targets, FieldName );
if( string.IsNullOrEmpty( LHSprop.name ) )
{
LHSprop = MaterialEditor.GetMaterialProperty( prop.targets, "_" + FieldName.Replace( " ", "" ) );
if( string.IsNullOrEmpty( LHSprop.name ) )
{
EditorGUI.LabelField( position, "EditableIf Attribute Error: " + FieldName + " Does not exist!" );
return;
}
}
object LHSVal = null;
bool test = false;
switch( LHSprop.type )
{
case MaterialProperty.PropType.Color:
case MaterialProperty.PropType.Vector:
LHSVal = LHSprop.type == MaterialProperty.PropType.Color ? (Vector4)LHSprop.colorValue : LHSprop.vectorValue;
var v4 = ExpectedValue as Vector4?;
v4 = v4.HasValue ? v4 : new Vector4( (System.Single)ExpectedValue, float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity );
if( LHSprop.type == MaterialProperty.PropType.Color )
{
test = VectorCheck( (Vector4)LHSVal, op, v4 / 255 );
}
else
test = VectorCheck( (Vector4)LHSVal, op, v4 );
break;
case MaterialProperty.PropType.Range:
case MaterialProperty.PropType.Float:
LHSVal = LHSprop.floatValue;
test = ( Check( LHSVal, op, ExpectedValue ) );
break;
case MaterialProperty.PropType.Texture:
LHSVal = LHSprop.textureValue;
test = ( CheckObject( LHSVal, op, ExpectedValue ) );
break;
}
GUI.enabled = test;
editor.DefaultShaderProperty( position, prop, label );
GUI.enabled = true;
}
private bool VectorCheck( Vector4 LHS, ComparisonOperators op, object expectedValue )
{
var RHS = (Vector4)expectedValue;
if( RHS.x != float.NegativeInfinity )
{
if( !Check( LHS.x, op, RHS.x ) )
return false;
}
if( RHS.y != float.NegativeInfinity )
{
if( !Check( LHS.y, op, RHS.y ) )
return false;
}
if( RHS.z != float.NegativeInfinity )
{
if( !Check( LHS.z, op, RHS.z ) )
return false;
}
if( RHS.w != float.NegativeInfinity )
{
if( !Check( LHS.w, op, RHS.w ) )
return false;
}
return true;
}
protected bool Check( object LHS, ComparisonOperators op, object RHS )
{
if( !( LHS is IComparable ) || !( RHS is IComparable ) )
throw new Exception( "Check using non basic type" );
switch( op )
{
case ComparisonOperators.EqualTo:
return ( (IComparable)LHS ).CompareTo( RHS ) == 0;
case ComparisonOperators.NotEqualTo:
return ( (IComparable)LHS ).CompareTo( RHS ) != 0;
case ComparisonOperators.EqualsOrGreaterThan:
return ( (IComparable)LHS ).CompareTo( RHS ) >= 0;
case ComparisonOperators.EqualsOrLessThan:
return ( (IComparable)LHS ).CompareTo( RHS ) <= 0;
case ComparisonOperators.GreaterThan:
return ( (IComparable)LHS ).CompareTo( RHS ) > 0;
case ComparisonOperators.LessThan:
return ( (IComparable)LHS ).CompareTo( RHS ) < 0;
case ComparisonOperators.ContainsFlags:
return ( (int)LHS & (int)RHS ) != 0; // Dont trust LHS values, it has been casted to a char and then to an int again, first bit will be the sign
case ComparisonOperators.DoesNotContainsFlags:
return ( ( (int)LHS & (int)RHS ) == (int)LHS ); // Dont trust LHS values, it has been casted to a char and then to an int again, first bit will be the sign
default:
break;
}
return false;
}
private bool CheckObject( object LHS, ComparisonOperators comparasonOperator, object RHS )
{
switch( comparasonOperator )
{
case ComparisonOperators.EqualTo:
return ( LHS == null );
case ComparisonOperators.NotEqualTo:
return ( LHS != null );
}
return true;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7a5504a2b7d04a846978416748dc6e0a
timeCreated: 1520330108
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
public class NoKeywordToggle : MaterialPropertyDrawer
{
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor) {
bool value = (prop.floatValue != 0.0f);
EditorGUI.BeginChangeCheck();
{
EditorGUI.showMixedValue = prop.hasMixedValue;
value = EditorGUI.Toggle( position, label, value );
EditorGUI.showMixedValue = false;
}
if (EditorGUI.EndChangeCheck())
{
prop.floatValue = value ? 1.0f : 0.0f;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e1a000d43a26286499b39a7571e5c61b
timeCreated: 1605540234
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,36 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
public class RemapSliders : MaterialPropertyDrawer
{
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
EditorGUI.BeginChangeCheck();
Vector4 value = prop.vectorValue;
EditorGUI.showMixedValue = prop.hasMixedValue;
var cacheLabel = EditorGUIUtility.labelWidth;
var cacheField = EditorGUIUtility.fieldWidth;
if( cacheField <= 64 )
{
float total = position.width;
EditorGUIUtility.labelWidth = Mathf.Ceil( 0.45f * total ) - 30;
EditorGUIUtility.fieldWidth = Mathf.Ceil( 0.55f * total ) + 30;
}
EditorGUI.MinMaxSlider(position, label, ref value.x, ref value.y, 0, 1 );
EditorGUIUtility.labelWidth = cacheLabel;
EditorGUIUtility.fieldWidth = cacheField;
EditorGUI.showMixedValue = false;
if( EditorGUI.EndChangeCheck() )
{
prop.vectorValue = value;
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 230fe34542e175245ba74b4659dae700
guid: 314af1bcecbba6c4d92cbb5843c221ba
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,36 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
public class RemapSlidersFull : MaterialPropertyDrawer
{
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
EditorGUI.BeginChangeCheck();
Vector4 value = prop.vectorValue;
EditorGUI.showMixedValue = prop.hasMixedValue;
var cacheLabel = EditorGUIUtility.labelWidth;
var cacheField = EditorGUIUtility.fieldWidth;
if( cacheField <= 64 )
{
float total = position.width;
EditorGUIUtility.labelWidth = Mathf.Ceil( 0.45f * total ) - 30;
EditorGUIUtility.fieldWidth = Mathf.Ceil( 0.55f * total ) + 30;
}
EditorGUI.MinMaxSlider( position, label, ref value.x, ref value.y, value.z, value.w );
EditorGUIUtility.labelWidth = cacheLabel;
EditorGUIUtility.fieldWidth = cacheField;
EditorGUI.showMixedValue = false;
if( EditorGUI.EndChangeCheck() )
{
prop.vectorValue = value;
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 188918ab119d93148aa0de59ccf5286b
guid: 9a724dcf5c5ddef40bcef06f0b2c8ec0
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,23 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
public class SingleLineTexture : MaterialPropertyDrawer
{
public override void OnGUI( Rect position, MaterialProperty prop, String label, MaterialEditor editor )
{
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = prop.hasMixedValue;
Texture value = editor.TexturePropertyMiniThumbnail( position, prop, label, string.Empty );
EditorGUI.showMixedValue = false;
if( EditorGUI.EndChangeCheck() )
{
prop.textureValue = value;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 85da32683d237ac4f8665251e2ac38dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,17 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEditor;
using UnityEditor.ProjectWindowCallback;
namespace AmplifyShaderEditor
{
public class DoCreateFunction : EndNameEditAction
{
public override void Action( int instanceId, string pathName, string resourceFile )
{
UnityEngine.Object obj = EditorUtility.InstanceIDToObject( instanceId );
AssetDatabase.CreateAsset( obj, AssetDatabase.GenerateUniqueAssetPath( pathName ) );
AmplifyShaderEditorWindow.LoadShaderFunctionToASE( (AmplifyShaderFunction)obj, false );
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3f2c950b0ed192943b7484f6b551965f
timeCreated: 1493906087
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,48 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using UnityEditor.ProjectWindowCallback;
using System.IO;
namespace AmplifyShaderEditor
{
public class DoCreateStandardShader : EndNameEditAction
{
public override void Action( int instanceId, string pathName, string resourceFile )
{
string uniquePath = AssetDatabase.GenerateUniqueAssetPath( pathName );
string shaderName = Path.GetFileName( uniquePath );
if( IOUtils.AllOpenedWindows.Count > 0 )
{
EditorWindow openedWindow = AmplifyShaderEditorWindow.GetWindow<AmplifyShaderEditorWindow>();
AmplifyShaderEditorWindow currentWindow = AmplifyShaderEditorWindow.CreateTab();
WindowHelper.AddTab( openedWindow, currentWindow );
UIUtils.CurrentWindow = currentWindow;
}
else
{
AmplifyShaderEditorWindow currentWindow = AmplifyShaderEditorWindow.OpenWindow( shaderName, UIUtils.ShaderIcon );
UIUtils.CurrentWindow = currentWindow;
}
Shader shader = UIUtils.CreateNewEmpty( uniquePath, shaderName );
ProjectWindowUtil.ShowCreatedAsset( shader );
}
}
public class DoCreateTemplateShader : EndNameEditAction
{
public override void Action( int instanceId, string pathName, string resourceFile )
{
string uniquePath = AssetDatabase.GenerateUniqueAssetPath( pathName );
string shaderName = Path.GetFileName( uniquePath );
if( !string.IsNullOrEmpty( UIUtils.NewTemplateGUID ) )
{
Shader shader = AmplifyShaderEditorWindow.CreateNewTemplateShader( UIUtils.NewTemplateGUID, uniquePath, shaderName );
ProjectWindowUtil.ShowCreatedAsset( shader );
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2cfa7290f61ad684f99f8d81328ad52c
timeCreated: 1573664425
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,67 @@
using UnityEditor;
namespace AmplifyShaderEditor
{
[System.Serializable]
public class OptionsWindow
{
private AmplifyShaderEditorWindow m_parentWindow = null;
private bool m_coloredPorts = true;
private bool m_multiLinePorts = true;
private const string MultiLineId = "MultiLinePortsDefault";
private const string ColorPortId = "ColoredPortsDefault";
public OptionsWindow( AmplifyShaderEditorWindow parentWindow )
{
m_parentWindow = parentWindow;
//Load ();
}
public void Init()
{
Load();
}
public void Destroy()
{
Save();
}
public void Save()
{
EditorPrefs.SetBool( ColorPortId, ColoredPorts );
EditorPrefs.SetBool( MultiLineId, m_multiLinePorts );
}
public void Load()
{
ColoredPorts = EditorPrefs.GetBool( ColorPortId, true );
m_multiLinePorts = EditorPrefs.GetBool( MultiLineId, true );
}
public bool ColoredPorts
{
get { return m_coloredPorts; }
set
{
if ( m_coloredPorts != value )
EditorPrefs.SetBool( ColorPortId, value );
m_coloredPorts = value;
}
}
public bool MultiLinePorts
{
get { return m_multiLinePorts; }
set
{
if ( m_multiLinePorts != value )
EditorPrefs.SetBool( MultiLineId, value );
m_multiLinePorts = value;
}
}
public AmplifyShaderEditorWindow ParentWindow { get { return m_parentWindow; } set { m_parentWindow = value; } }
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 44cb06bc7bfe6e84aa8b5e8b702eb2dd
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 52f451731ec183e43ab18f0896f7172a
folderAsset: yes
timeCreated: 1481126944
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,283 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace AmplifyShaderEditor
{
public class NodeGrid
{
private bool m_debugGrid = false;
private const float GRID_SIZE_X = 100;
private const float GRID_SIZE_Y = 100;
private const float GRID_AREA_X = 1000;
private const float GRID_AREA_Y = 1000;
private Dictionary<int, Dictionary<int, List<ParentNode>>> m_grid;
private int m_xMin = int.MaxValue;
private int m_yMin = int.MaxValue;
private int m_xMax = int.MinValue;
private int m_yMax = int.MinValue;
public NodeGrid()
{
m_grid = new Dictionary<int, Dictionary<int, List<ParentNode>>>();
}
public void AddNodeToGrid( ParentNode node )
{
Rect pos = node.Position;
if ( Mathf.Abs( pos.width ) < 0.001f || Mathf.Abs( pos.height ) < 0.001f )
{
return;
}
float initialXf = pos.x / GRID_SIZE_X;
float initialYf = pos.y / GRID_SIZE_Y;
int endX = Mathf.CeilToInt( initialXf + pos.width / GRID_SIZE_X );
int endY = Mathf.CeilToInt( initialYf + pos.height / GRID_SIZE_Y );
int initialX = Mathf.FloorToInt( initialXf );
int initialY = Mathf.FloorToInt( initialYf );
if ( initialX < m_xMin )
{
m_xMin = initialX;
}
if ( initialY < m_yMin )
{
m_yMin = initialY;
}
if ( endX > m_xMax )
{
m_xMax = endX;
}
if ( endY > m_yMax )
{
m_yMax = endY;
}
for ( int x = initialX; x < endX; x += 1 )
{
for ( int y = initialY; y < endY; y += 1 )
{
if ( !m_grid.ContainsKey( x ) )
{
m_grid.Add( x, new Dictionary<int, List<ParentNode>>() );
}
if ( !m_grid[ x ].ContainsKey( y ) )
{
m_grid[ x ].Add( y, new List<ParentNode>() );
}
m_grid[ x ][ y ].Add( node );
}
}
node.IsOnGrid = true;
//DebugLimits();
}
public void RemoveNodeFromGrid( ParentNode node, bool useCachedPos )
{
Rect pos = useCachedPos ? node.CachedPos : node.Position;
if ( Mathf.Abs( pos.width ) < 0.001f || Mathf.Abs( pos.height ) < 0.001f )
{
return;
}
float initialXf = pos.x / GRID_SIZE_X;
float initialYf = pos.y / GRID_SIZE_Y;
int endX = Mathf.CeilToInt( initialXf + pos.width / GRID_SIZE_X );
int endY = Mathf.CeilToInt( initialYf + pos.height / GRID_SIZE_Y );
int initialX = Mathf.FloorToInt( initialXf );
int initialY = Mathf.FloorToInt( initialYf );
bool testLimits = false;
int xMinCount = 0;
int xMaxCount = 0;
int yMinCount = 0;
int yMaxCount = 0;
for ( int x = initialX; x < endX; x += 1 )
{
for ( int y = initialY; y < endY; y += 1 )
{
if ( m_grid.ContainsKey( x ) )
{
if ( m_grid[ x ].ContainsKey( y ) )
{
m_grid[ x ][ y ].Remove( node );
node.IsOnGrid = false;
if ( initialX == m_xMin && x == initialX )
{
testLimits = true;
if ( m_grid[ x ][ y ].Count != 0 )
{
xMinCount += 1;
}
}
if ( endX == m_xMax && x == endX )
{
testLimits = true;
if ( m_grid[ x ][ y ].Count != 0 )
{
xMaxCount += 1;
}
}
if ( initialY == m_yMin && y == initialY )
{
testLimits = true;
if ( m_grid[ x ][ y ].Count != 0 )
{
yMinCount += 1;
}
}
if ( endY == m_yMax && y == endY )
{
testLimits = true;
if ( m_grid[ x ][ y ].Count != 0 )
{
yMaxCount += 1;
}
}
}
}
}
}
if ( testLimits )
{
if ( xMinCount == 0 || xMaxCount == 0 || yMinCount == 0 || yMaxCount == 0 )
{
m_xMin = int.MaxValue;
m_yMin = int.MaxValue;
m_xMax = int.MinValue;
m_yMax = int.MinValue;
foreach ( KeyValuePair<int, Dictionary<int, List<ParentNode>>> entryX in m_grid )
{
foreach ( KeyValuePair<int, List<ParentNode>> entryY in entryX.Value )
{
if ( entryY.Value.Count > 0 )
{
if ( entryX.Key < m_xMin )
{
m_xMin = entryX.Key;
}
if ( entryY.Key < m_yMin )
{
m_yMin = entryY.Key;
}
if ( entryX.Key > m_xMax )
{
m_xMax = entryX.Key;
}
if ( entryY.Key > m_yMax )
{
m_yMax = entryY.Key;
}
}
}
}
// The += 1 is to maintain consistence with AddNodeToGrid() ceil op on max values
m_xMax += 1;
m_yMax += 1;
}
}
//DebugLimits();
}
public void DebugLimits()
{
Debug.Log( "[ " + m_xMin + " , " + m_yMin + " ] " + "[ " + m_xMax + " , " + m_yMax + " ] " );
}
//pos must be the transformed mouse position to local canvas coordinates
public List<ParentNode> GetNodesOn( Vector2 pos )
{
int x = Mathf.FloorToInt( pos.x / GRID_SIZE_X );
int y = Mathf.FloorToInt( pos.y / GRID_SIZE_Y );
if ( m_grid.ContainsKey( x ) )
{
if ( m_grid[ x ].ContainsKey( y ) )
{
return m_grid[ x ][ y ];
}
}
return null;
}
public List<ParentNode> GetNodesOn( int x, int y )
{
if ( m_grid.ContainsKey( x ) )
{
if ( m_grid[ x ].ContainsKey( y ) )
{
return m_grid[ x ][ y ];
}
}
return null;
}
public void DrawGrid( DrawInfo drawInfo )
{
if ( m_debugGrid )
{
Handles.CircleHandleCap( 0, drawInfo.InvertedZoom * ( new Vector3( drawInfo.CameraOffset.x, drawInfo.CameraOffset.y, 0f ) ), Quaternion.identity, 5,EventType.Layout );
for ( int x = -( int ) GRID_AREA_X; x < GRID_AREA_X; x += ( int ) GRID_SIZE_X )
{
Handles.DrawLine( drawInfo.InvertedZoom * ( new Vector3( x + drawInfo.CameraOffset.x, drawInfo.CameraOffset.y - GRID_AREA_Y, 0 ) ), drawInfo.InvertedZoom * ( new Vector3( drawInfo.CameraOffset.x + x, drawInfo.CameraOffset.y + GRID_AREA_Y, 0 ) ) );
}
for ( int y = -( int ) GRID_AREA_Y; y < GRID_AREA_X; y += ( int ) GRID_SIZE_Y )
{
Handles.DrawLine( drawInfo.InvertedZoom * ( new Vector3( drawInfo.CameraOffset.x - GRID_AREA_X, drawInfo.CameraOffset.y + y, 0 ) ), drawInfo.InvertedZoom * ( new Vector3( drawInfo.CameraOffset.x + GRID_AREA_X, drawInfo.CameraOffset.y + y, 0 ) ) );
}
}
}
public void Destroy()
{
foreach ( KeyValuePair<int, Dictionary<int, List<ParentNode>>> entryX in m_grid )
{
foreach ( KeyValuePair<int, List<ParentNode>> entryY in entryX.Value )
{
entryY.Value.Clear();
}
entryX.Value.Clear();
}
m_grid.Clear();
}
public float MaxNodeDist
{
get { return Mathf.Max( ( m_xMax - m_xMin )*GRID_SIZE_X, ( m_yMax - m_yMin )*GRID_SIZE_Y ); }
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6344917ce0eed6b43840632b98a2ed57
timeCreated: 1481126956
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0b814c2a3cbebc047a566a92ed9d4340
timeCreated: 1481126953
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3b28c70161e2aec4787239fba546bd25
folderAsset: yes
timeCreated: 1481126944
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c8bcac0d66f920e49803925a85beb0ed
timeCreated: 1481126959
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,189 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
using AmplifyShaderEditor;
[Serializable]
public class AmplifyShaderFunction : ScriptableObject
{
[SerializeField]
private string m_functionInfo = string.Empty;
public string FunctionInfo
{
get { return m_functionInfo; }
set { m_functionInfo = value; }
}
[SerializeField]
private string m_functionName = string.Empty;
public string FunctionName
{
get { if( m_functionName.Length == 0 ) return name; else return m_functionName; }
set { m_functionName = value; }
}
[SerializeField]
[TextArea( 5, 15 )]
private string m_description = string.Empty;
public string Description
{
get { return m_description; }
set { m_description = value; }
}
[SerializeField]
private AdditionalIncludesHelper m_additionalIncludes = new AdditionalIncludesHelper();
//public AdditionalIncludesHelper AdditionalIncludes
//{
// get { return m_additionalIncludes; }
// set { m_additionalIncludes = value; }
//}
[SerializeField]
private AdditionalPragmasHelper m_additionalPragmas = new AdditionalPragmasHelper();
//public AdditionalPragmasHelper AdditionalPragmas
//{
// get { return m_additionalPragmas; }
// set { m_additionalPragmas = value; }
//}
[SerializeField]
private TemplateAdditionalDirectivesHelper m_additionalDirectives = new TemplateAdditionalDirectivesHelper( " Additional Directives" );
public TemplateAdditionalDirectivesHelper AdditionalDirectives
{
get { return m_additionalDirectives; }
set { m_additionalDirectives = value; }
}
[SerializeField]
private FunctionNodeCategories m_nodeCategory = FunctionNodeCategories.Functions;
public FunctionNodeCategories NodeCategory
{
get { return m_nodeCategory; }
set { m_nodeCategory = value; }
}
[SerializeField]
private string m_customNodeCategory = string.Empty;
public string CustomNodeCategory
{
get
{
if( m_nodeCategory == FunctionNodeCategories.Custom )
{
if( string.IsNullOrEmpty( m_customNodeCategory ) )
return "Functions";
else
return m_customNodeCategory;
}
else
{
return UIUtils.CategoryPresets[ (int)m_nodeCategory ];
//return new SerializedObject( this ).FindProperty( "m_nodeCategory" ).enumDisplayNames[ (int)m_nodeCategory ];
}
}
}
[SerializeField]
private PreviewLocation m_previewPosition = PreviewLocation.Auto;
public PreviewLocation PreviewPosition
{
get { return m_previewPosition; }
set { m_previewPosition = value; }
}
[SerializeField]
private bool m_hidden = false;
public bool Hidden
{
get { return m_hidden; }
set { m_hidden = value; }
}
public void UpdateDirectivesList()
{
m_additionalDirectives.CleanNullDirectives();
m_additionalDirectives.UpdateDirectivesFromSaveItems();
if( m_additionalIncludes.IncludeList.Count > 0 )
{
m_additionalDirectives.AddItems( AdditionalLineType.Include, m_additionalIncludes.IncludeList );
m_additionalIncludes.IncludeList.Clear();
}
if( m_additionalPragmas.PragmaList.Count > 0 )
{
m_additionalDirectives.AddItems( AdditionalLineType.Pragma, m_additionalPragmas.PragmaList );
m_additionalPragmas.PragmaList.Clear();
}
}
public void ResetDirectivesOrigin()
{
//if( UIUtils.CurrentShaderVersion() < 16807 )
// Although the correct version was 1.6.7 rev 07 this issue was only detected on v1.7.1. rev 00
// So to avoid potential incorrect saves over shader functions, I decided to broaden up the version range
if( UIUtils.CurrentShaderVersion() < 17101 )
{
m_additionalDirectives.ResetDirectivesOrigin();
}
}
}
public class ShaderFunctionDetector : AssetPostprocessor
{
static void OnPostprocessAllAssets( string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths )
{
if( UIUtils.CurrentWindow == null )
return;
bool markForRefresh = false;
AmplifyShaderFunction function = null;
for( int i = 0; i < importedAssets.Length; i++ )
{
function = AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( importedAssets[ i ] );
if( function != null )
{
markForRefresh = true;
break;
}
}
if( deletedAssets.Length > 0 )
markForRefresh = true;
for( int i = 0; i < movedAssets.Length; i++ )
{
function = AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( movedAssets[ i ] );
if( function != null )
{
markForRefresh = true;
break;
}
}
for( int i = 0; i < movedFromAssetPaths.Length; i++ )
{
function = AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( movedFromAssetPaths[ i ] );
if( function != null )
{
markForRefresh = true;
break;
}
}
if( markForRefresh )
{
markForRefresh = false;
if( function != null )
{
IOUtils.UpdateSFandRefreshWindows( function );
}
UIUtils.CurrentWindow.LateRefreshAvailableNodes();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 78b2425a2284af743826c689403a4924
timeCreated: 1492703397
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 50be8291f9514914aa55c66c49da67cf, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,168 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Text.RegularExpressions;
using System.IO;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
[CustomEditor( typeof( AmplifyShaderFunction ) )]
public class AmplifyShaderFunctionEditor : Editor
{
class FunctionDependency
{
public string AssetName;
public string AssetPath;
public FunctionDependency(string name, string path)
{
AssetName = name;
AssetPath = path;
}
}
AmplifyShaderFunction m_target;
List<FunctionDependency> m_dependencies = new List<FunctionDependency>();
void OnEnable()
{
m_target = ( target as AmplifyShaderFunction );
}
public override void OnInspectorGUI()
{
//base.OnInspectorGUI();
//base.serializedObject.Update();
if( GUILayout.Button( "Open in Shader Editor" ) )
{
#if UNITY_2018_3_OR_NEWER
ASEPackageManagerHelper.SetupLateShaderFunction( m_target );
#else
AmplifyShaderEditorWindow.LoadShaderFunctionToASE( m_target, false );
#endif
}
//EditorGUILayout.Separator();
//m_target.FunctionInfo = EditorGUILayout.TextArea( m_target.FunctionInfo );
if( m_target.Description.Length > 0 )
{
EditorGUILayout.HelpBox( m_target.Description, MessageType.Info );
}
EditorGUILayout.Space();
if( GUILayout.Button( "Search Direct Dependencies" ) )
{
m_dependencies.Clear();
string guid = AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_target ) );
string[] allSFs = AssetDatabase.FindAssets( "t:AmplifyShaderFunction", null );
foreach( string guid1 in allSFs )
{
string sfPath = AssetDatabase.GUIDToAssetPath( guid1 );
bool found = SearchForGUID( guid, sfPath );
if( found )
{
//string n = Regex.Replace( sfPath, @"(\.\w+|[\w\d\/]+\/)", "" );
string n = Regex.Replace( sfPath, @"[\w\d\/]+\/", "" );
m_dependencies.Add(new FunctionDependency( n, sfPath ) );
}
}
string[] allSHs = AssetDatabase.FindAssets( "t:Shader", null );
foreach( string guid1 in allSHs )
{
string shPath = AssetDatabase.GUIDToAssetPath( guid1 );
bool found = SearchForGUID( guid, shPath );
if( found )
{
string n = Regex.Replace( shPath, @"[\w\d\/]+\/", "" );
m_dependencies.Add( new FunctionDependency( n, shPath ) );
}
}
}
EditorGUILayout.Space();
for( int i = 0; i < m_dependencies.Count; i++ )
{
EditorGUILayout.BeginHorizontal();
if( GUILayout.Button( m_dependencies[ i ].AssetName, "minibuttonleft" ) )
{
SelectAtPath( m_dependencies[ i ].AssetPath );
}
if( GUILayout.Button( "edit", "minibuttonright", GUILayout.Width(100) ) )
{
if( m_dependencies[ i ].AssetName.EndsWith( ".asset" ) )
{
var obj = AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( m_dependencies[ i ].AssetPath );
AmplifyShaderEditorWindow.LoadShaderFunctionToASE( obj, false );
}
else
{
var obj = AssetDatabase.LoadAssetAtPath<Shader>( m_dependencies[ i ].AssetPath );
AmplifyShaderEditorWindow.ConvertShaderToASE( obj );
}
}
EditorGUILayout.EndHorizontal();
}
if( m_dependencies.Count > 0 )
{
List<string> assetPaths = new List<string>();
for( int i = 0; i < m_dependencies.Count; i++ )
{
assetPaths.Add( m_dependencies[ i ].AssetPath );
}
if( GUILayout.Button( "Open and Save All" ) )
{
bool doit = EditorUtility.DisplayDialog( "Open and Save All", "This will try to open all shader function and shaders that use this shader function and save them in quick succession, this may irreversibly break your files if something goes wrong. Are you sure you want to try?", "Yes, I'll take the risk", "No, I'll do it myself" );
if( doit )
AmplifyShaderEditorWindow.LoadAndSaveList( assetPaths.ToArray() );
}
}
}
public void SelectAtPath( string path )
{
var obj = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>( path );
EditorGUIUtility.PingObject( obj );
}
public static bool SearchForGUID( string guid, string pathName )
{
bool result = false;
int count = 0;
if( !string.IsNullOrEmpty( pathName ) && File.Exists( pathName ) )
{
StreamReader fileReader = null;
try
{
fileReader = new StreamReader( pathName );
string line;
int index = -1;
while( ( line = fileReader.ReadLine() ) != null )
{
index = line.IndexOf( guid );
count++;
if( index > -1 )
{
result = true;
break;
}
}
}
catch( Exception e )
{
Debug.LogException( e );
}
finally
{
if( fileReader != null )
fileReader.Close();
}
}
return result;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8b2d6d1320661374db53aeb8057312b2
timeCreated: 1491909065
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,94 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
namespace AmplifyShaderEditor
{
public enum AutoPanLocation
{
TOP = 0,
BOTTOM,
LEFT,
RIGHT
}
public class AutoPanData
{
private Rect m_area;
private float m_size;
private Vector2 m_velocity;
private GUIStyle m_style;
private Color m_color = new Color( 1f, 0f, 0f, 0.5f );
private AutoPanLocation m_location;
private float m_adjustWidth = 0;
private float m_adjustInitialX = 0;
public AutoPanData( AutoPanLocation location, float size, Vector2 vel )
{
m_area = new Rect();
m_size = size;
m_velocity = vel;
m_location = location;
}
public bool CheckArea( Vector2 mousePosition, Rect window, bool draw )
{
float totalSize = m_size + m_adjustWidth;
switch ( m_location )
{
case AutoPanLocation.TOP:
{
m_area.x = m_adjustInitialX;
m_area.y = 0;
m_area.width = window.width;
m_area.height = totalSize;
}
break;
case AutoPanLocation.BOTTOM:
{
m_area.x = m_adjustInitialX;
m_area.y = window.height - totalSize;
m_area.width = window.width;
m_area.height = totalSize;
}
break;
case AutoPanLocation.LEFT:
{
m_area.x = m_adjustInitialX;
m_area.y = 0;
m_area.width = totalSize;
m_area.height = window.height;
}
break;
case AutoPanLocation.RIGHT:
{
m_area.x = m_adjustInitialX + window.width - totalSize;
m_area.y = 0;
m_area.width = totalSize;
m_area.height = window.height;
}
break;
}
if ( draw )
{
if ( m_style == null )
{
m_style = UIUtils.Box;
}
Color bufferedColor = GUI.color;
GUI.color = m_color;
GUI.Label( m_area, string.Empty, m_style );
GUI.color = bufferedColor;
}
return m_area.Contains( mousePosition );
}
public float AdjustWidth { set { m_adjustWidth = value; } }
public float AdjustInitialX { set { m_adjustInitialX = value; } }
public Vector2 Velocity { get { return m_velocity; } }
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 711db07e8265cb740940568c4bc7345f
timeCreated: 1481126956
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,262 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
namespace AmplifyShaderEditor
{
public class ClipboardData
{
public string Data = string.Empty;
public string Connections = string.Empty;
public int OldNodeId = -1;
public int NewNodeId = -1;
public ClipboardData( string data, string connections, int oldNodeId )
{
Data = data;
Connections = connections;
OldNodeId = oldNodeId;
}
public override string ToString()
{
return Data + IOUtils.CLIPBOARD_DATA_SEPARATOR + Connections + IOUtils.CLIPBOARD_DATA_SEPARATOR + OldNodeId + IOUtils.CLIPBOARD_DATA_SEPARATOR + NewNodeId;
}
}
public class Clipboard
{
public const string ClipboardId = "AMPLIFY_CLIPBOARD_ID";
private readonly string[] ClipboardTagId = { "#CLIP_ITEM#" };
private List<ClipboardData> m_clipboardStrData;
private Dictionary<int, ClipboardData> m_clipboardAuxData;
private Dictionary<string, ClipboardData> m_multiPassMasterNodeData;
public Clipboard()
{
m_clipboardStrData = new List<ClipboardData>();
m_clipboardAuxData = new Dictionary<int, ClipboardData>();
m_multiPassMasterNodeData = new Dictionary<string, ClipboardData>();
}
public void ResetMultipassNodesData()
{
m_multiPassMasterNodeData.Clear();
}
public void AddMultiPassNodesToClipboard( List<TemplateMultiPassMasterNode> masterNodes, bool resetList, int lodId )
{
if( resetList )
m_multiPassMasterNodeData.Clear();
int templatesAmount = masterNodes.Count;
for( int i = 0; i < templatesAmount; i++ )
{
if( !masterNodes[ i ].InvalidNode )
{
string data = string.Empty;
string connection = string.Empty;
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
masterNodes[ i ].FullWriteToString( ref data, ref connection );
System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
ClipboardData clipboardData = new ClipboardData( data, connection, masterNodes[ i ].UniqueId );
m_multiPassMasterNodeData.Add( masterNodes[ i ].PassUniqueName + lodId, clipboardData );
}
}
}
public void GetMultiPassNodesFromClipboard( List<TemplateMultiPassMasterNode> masterNodes, int lodId )
{
int templatesAmount = masterNodes.Count;
for( int i = 0; i < templatesAmount; i++ )
{
string clipboardDataId = masterNodes[ i ].PassUniqueName + lodId;
if( m_multiPassMasterNodeData.ContainsKey( clipboardDataId ) )
{
ClipboardData nodeData = m_multiPassMasterNodeData[ clipboardDataId ];
string[] nodeParams = nodeData.Data.Split( IOUtils.FIELD_SEPARATOR );
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
masterNodes[ i ].FullReadFromString( ref nodeParams );
System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
}
}
for( int i = 0; i < templatesAmount; i++ )
{
string clipboardDataId = masterNodes[ i ].PassUniqueName + lodId;
if( m_multiPassMasterNodeData.ContainsKey( clipboardDataId ) )
{
masterNodes[ i ].SetReadOptions();
masterNodes[ i ].ForceOptionsRefresh();
}
}
}
public void AddToClipboard( List<ParentNode> selectedNodes , Vector3 initialPosition, ParentGraph graph )
{
//m_clipboardStrData.Clear();
//m_clipboardAuxData.Clear();
string clipboardData = IOUtils.Vector3ToString( initialPosition ) + ClipboardTagId[ 0 ];
int masterNodeId = UIUtils.CurrentWindow.CurrentGraph.CurrentMasterNodeId;
int count = selectedNodes.Count;
for ( int i = 0; i < count; i++ )
{
if ( UIUtils.CurrentWindow.IsShaderFunctionWindow || !graph.IsMasterNode( selectedNodes[ i ] ))
{
string nodeData = string.Empty;
string connections = string.Empty;
selectedNodes[ i ].ClipboardFullWriteToString( ref nodeData, ref connections );
clipboardData += nodeData;
if ( !string.IsNullOrEmpty( connections ) )
{
connections = connections.Substring( 0, connections.Length - 1 );
clipboardData += "\n" + connections;
}
if ( i < count - 1 )
clipboardData += ClipboardTagId[ 0 ];
//ClipboardData data = new ClipboardData( nodeData, connections, selectedNodes[ i ].UniqueId );
//m_clipboardStrData.Add( data );
//m_clipboardAuxData.Add( selectedNodes[ i ].UniqueId, data );
}
}
if ( !string.IsNullOrEmpty( clipboardData ) )
{
EditorPrefs.SetString( ClipboardId, clipboardData );
}
//for ( int i = 0; i < selectedNodes.Count; i++ )
//{
// if ( selectedNodes[ i ].UniqueId != masterNodeId )
// {
// WireNode wireNode = selectedNodes[ i ] as WireNode;
// if ( wireNode != null )
// {
// if ( !IsNodeChainValid( selectedNodes[ i ], true ) || !IsNodeChainValid( selectedNodes[ i ], false ) )
// {
// UnityEngine.Debug.Log( "found invalid wire port" );
// }
// }
// }
//}
}
public Vector3 GetDataFromEditorPrefs()
{
Vector3 initialPos = Vector3.zero;
m_clipboardStrData.Clear();
m_clipboardAuxData.Clear();
string clipboardData = EditorPrefs.GetString( ClipboardId, string.Empty );
if ( !string.IsNullOrEmpty( clipboardData ) )
{
string[] clipboardDataArray = clipboardData.Split( ClipboardTagId, StringSplitOptions.None );
initialPos = IOUtils.StringToVector3( clipboardDataArray[0] );
for ( int i = 1; i < clipboardDataArray.Length; i++ )
{
if ( !string.IsNullOrEmpty( clipboardDataArray[ i ] ) )
{
int wiresIndex = clipboardDataArray[ i ].IndexOf( IOUtils.LINE_TERMINATOR );
string nodeData = string.Empty;
string connections = string.Empty;
if ( wiresIndex < 0 )
{
nodeData = clipboardDataArray[ i ];
}
else
{
nodeData = clipboardDataArray[ i ].Substring( 0, wiresIndex );
connections = clipboardDataArray[ i ].Substring( wiresIndex + 1 );
}
string[] nodeDataArr = nodeData.Split( IOUtils.FIELD_SEPARATOR );
if ( nodeDataArr.Length > 2 )
{
int nodeId = Convert.ToInt32( nodeDataArr[ 2 ] );
ClipboardData data = new ClipboardData( nodeData, connections, nodeId );
m_clipboardStrData.Add( data );
m_clipboardAuxData.Add( nodeId, data );
}
}
}
}
return initialPos;
}
public bool IsNodeChainValid( ParentNode currentNode, bool forward )
{
WireNode wireNode = currentNode as WireNode;
if ( wireNode == null )
{
return m_clipboardAuxData.ContainsKey( currentNode.UniqueId );
}
if ( forward )
{
if ( wireNode.InputPorts[ 0 ].ExternalReferences.Count > 0 )
{
int nodeId = wireNode.InputPorts[ 0 ].ExternalReferences[ 0 ].NodeId;
if ( m_clipboardAuxData.ContainsKey( nodeId ) )
{
return IsNodeChainValid( UIUtils.GetNode( nodeId ), forward );
}
}
}
else
{
int nodeId = wireNode.OutputPorts[ 0 ].ExternalReferences[ 0 ].NodeId;
if ( m_clipboardAuxData.ContainsKey( nodeId ) )
{
return IsNodeChainValid( UIUtils.GetNode( nodeId ), forward );
}
}
return false;
}
public void GenerateFullString()
{
string data = string.Empty;
for ( int i = 0; i < m_clipboardStrData.Count; i++ )
{
data += m_clipboardStrData[ i ].ToString();
if ( i < m_clipboardStrData.Count - 1 )
{
data += IOUtils.LINE_TERMINATOR;
}
}
}
public void ClearClipboard()
{
m_clipboardStrData.Clear();
m_clipboardAuxData.Clear();
m_multiPassMasterNodeData.Clear();
}
public ClipboardData GetClipboardData( int oldNodeId )
{
if ( m_clipboardAuxData.ContainsKey( oldNodeId ) )
return m_clipboardAuxData[ oldNodeId ];
return null;
}
public int GeNewNodeId( int oldNodeId )
{
if ( m_clipboardAuxData.ContainsKey( oldNodeId ) )
return m_clipboardAuxData[ oldNodeId ].NewNodeId;
return -1;
}
public List<ClipboardData> CurrentClipboardStrData
{
get { return m_clipboardStrData; }
}
public bool HasCachedMasterNodes { get { return m_multiPassMasterNodeData.Count > 0; } }
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8850a8c4f3ca99f42bbf602c671ffb7f
timeCreated: 1481126957
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,120 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEditor;
using UnityEngine;
namespace AmplifyShaderEditor
{
public class ConfirmationWindow
{
public delegate ShaderLoadResult OnConfirmationSelected( bool value, Shader shader, Material material );
public event OnConfirmationSelected OnConfirmationSelectedEvt;
private const string m_yesStr = "Yes";
private const string m_noStr = "No";
private bool m_isActive = false;
private string m_currentMessage;
private GUIStyle m_areaStyle;
private GUIContent m_content;
private GUIStyle m_buttonStyle;
private GUIStyle m_labelStyle;
private Shader m_shader;
private Material m_material;
private Rect m_area;
private bool m_autoDeactivate = true;
public ConfirmationWindow( float x, float y, float width, float height )
{
m_content = new GUIContent( GUIContent.none );
m_area = new Rect( x, y, width, height );
}
public void Destroy()
{
m_shader = null;
OnConfirmationSelectedEvt = null;
}
public void ActivateConfirmation( Shader shader, Material material, string message, OnConfirmationSelected evt, bool autoDeactivate = true )
{
OnConfirmationSelectedEvt = evt;
m_currentMessage = message;
m_shader = shader;
m_material = material;
m_autoDeactivate = autoDeactivate;
m_isActive = true;
}
public void OnGUI()
{
if ( m_areaStyle == null )
{
m_areaStyle = new GUIStyle( UIUtils.TextArea );
m_areaStyle.stretchHeight = true;
m_areaStyle.stretchWidth = true;
m_areaStyle.fontSize = ( int ) Constants.DefaultTitleFontSize;
}
if ( m_buttonStyle == null )
{
m_buttonStyle = UIUtils.Button;
}
if ( m_labelStyle == null )
{
m_labelStyle = new GUIStyle( UIUtils.Label );
m_labelStyle.alignment = TextAnchor.MiddleCenter;
m_labelStyle.wordWrap = true;
}
m_area.x = ( int ) ( 0.5f * UIUtils.CurrentWindow.CameraInfo.width );
m_area.y = ( int ) ( 0.5f * UIUtils.CurrentWindow.CameraInfo.height );
GUILayout.BeginArea( m_area, m_content, m_areaStyle );
{
EditorGUILayout.BeginVertical();
{
EditorGUILayout.Separator();
EditorGUILayout.LabelField( m_currentMessage, m_labelStyle );
EditorGUILayout.Separator();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
{
if ( GUILayout.Button( m_yesStr, m_buttonStyle ) )
{
if ( OnConfirmationSelectedEvt != null )
OnConfirmationSelectedEvt( true, m_shader, m_material );
if ( m_autoDeactivate )
Deactivate();
}
if ( GUILayout.Button( m_noStr, m_buttonStyle ) )
{
if ( OnConfirmationSelectedEvt != null )
OnConfirmationSelectedEvt( false, m_shader, m_material );
if ( m_autoDeactivate )
Deactivate();
}
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
}
GUILayout.EndArea();
}
public void Deactivate()
{
m_isActive = false;
OnConfirmationSelectedEvt = null;
}
public bool IsActive { get { return m_isActive; } }
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 291cb40a04f835a4d89037cf3053c6a3
timeCreated: 1481126954
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,309 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace AmplifyShaderEditor
{
[System.Serializable]
public class Toast
{
public MessageSeverity ItemType;
public string ItemMessage;
public double ItemTime;
public int ItemOwnerId;
public Toast( MessageSeverity itemType, string itemMessage, double itemTime,int itemOwnerId )
{
ItemType = itemType;
ItemMessage = itemMessage;
ItemTime = itemTime;
ItemOwnerId = itemOwnerId;
}
}
public class ConsoleLogWindow
{
public const int MAXWIDTH = 400;
public const float FADETIME = 7;
private readonly GUIContent m_boxToggleContent = new GUIContent( "\u2261", "Toggle Message Box" );
private readonly GUIContent m_clearContent = new GUIContent( "\u00D7", "Clear Messages" );
protected AmplifyShaderEditorWindow m_parentWindow = null;
// needs to be serialized
private Vector2 m_currentScrollPos;
int lastCall = -1;
public ConsoleLogWindow( AmplifyShaderEditorWindow parentWindow )
{
m_parentWindow = parentWindow;
}
public void AddMessage( MessageSeverity itemType, string itemMessage , int itemOwnerId )
{
var toast = new Toast( itemType, itemMessage, Time.realtimeSinceStartup, itemOwnerId );
m_parentWindow.Messages.Insert( 0, toast );
m_currentScrollPos.y = Mathf.Infinity;
if( !m_parentWindow.MaximizeMessages )
lastCall = Mathf.Max( (int)itemType, lastCall );
GUIContent gc = new GUIContent( m_parentWindow.Messages.Count + ": " + itemMessage );
float maxWidth = m_parentWindow.MaxMsgWidth;
maxWidth = Mathf.Max( GUIStyle.none.CalcSize( gc ).x + 16, maxWidth );
maxWidth = Mathf.Min( maxWidth, MAXWIDTH );
m_parentWindow.MaxMsgWidth = maxWidth;
}
public void Draw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus, float rightSide )
{
EventType currentEventType = Event.current.type;
var messages = m_parentWindow.Messages;
var maximize = m_parentWindow.MaximizeMessages;
Rect button = parentPosition;
button.width = 22;
button.height = 22;
button.x = parentPosition.x + parentPosition.width - button.width - rightSide - 8;
button.y = parentPosition.y + parentPosition.height - button.height - ( m_parentWindow.CurrentSelection == ASESelectionMode.Material ? 52 : 8 );
Rect toolbarArea = button;
toolbarArea.y -= 5;
if( maximize )
{
toolbarArea.xMin -= m_parentWindow.MaxMsgWidth;
toolbarArea.yMin -= 66;
}
toolbarArea.x -= 6;
bool needsRepaint = false;
if( maximize )
{
GUIStyle labelStyle = UIUtils.ConsoleLogLabel;
toolbarArea.y -= 16 + 8;
GUILayout.BeginArea( toolbarArea, UIUtils.ConsoleLogMessage );
EditorGUILayout.BeginVertical();
m_currentScrollPos = EditorGUILayout.BeginScrollView( m_currentScrollPos );
{
int count = messages.Count;
for( int i = count - 1; i >= 0; i-- )
{
switch( messages[ i ].ItemType )
{
case MessageSeverity.Error:
labelStyle.normal.textColor = Color.red;
break;
case MessageSeverity.Warning:
labelStyle.normal.textColor = Color.yellow;
break;
default:
case MessageSeverity.Normal:
labelStyle.normal.textColor = Color.white;
break;
}
if( messages[ i ].ItemOwnerId < 0 )
{
if( Event.current.control && Event.current.shift )
{
if( GUILayout.Button( ( count - i ) + ": " + messages[ i ].ItemMessage, labelStyle ) )
{
if( Event.current.button == 1 )
{
EditorGUIUtility.systemCopyBuffer = messages[ i ].ItemMessage;
}
}
}
else
{
GUILayout.Label( ( count - i ) + ": " + messages[ i ].ItemMessage, labelStyle );
}
}
else
{
if( GUILayout.Button( ( count - i ) + ": " + messages[ i ].ItemMessage, labelStyle ) )
{
UIUtils.CurrentWindow.FocusOnNode( messages[ i ].ItemOwnerId, 1, true );
if( Event.current.button == 1 )
{
EditorGUIUtility.systemCopyBuffer = messages[ i ].ItemMessage;
}
}
}
}
}
EditorGUILayout.EndScrollView();
EditorGUILayout.EndVertical();
GUILayout.EndArea();
}
else
{
// draw toaster
int count = messages.Count;
Rect rect = toolbarArea;
rect.xMin -= 200;
float startFade = FADETIME - 1;
for( int i = 0; i < count; i++ )
{
GUIStyle msgstyle = UIUtils.ConsoleLogMessage;
float delta = (float)(Time.realtimeSinceStartup - messages[ i ].ItemTime);
if( delta > FADETIME )
continue;
if( delta < 0.1f )
{
msgstyle.normal.textColor = Color.cyan;
}
else if( delta < startFade )
{
switch( messages[ i ].ItemType )
{
case MessageSeverity.Error:
msgstyle.normal.textColor = Color.red;
break;
case MessageSeverity.Warning:
msgstyle.normal.textColor = Color.yellow;
break;
default:
case MessageSeverity.Normal:
msgstyle.normal.textColor = Color.white;
break;
}
}
else
{
switch( messages[ i ].ItemType )
{
case MessageSeverity.Error:
msgstyle.normal.textColor = new Color( 1, 0, 0, FADETIME - delta );
break;
case MessageSeverity.Warning:
msgstyle.normal.textColor = new Color( 1, 1, 0, FADETIME - delta );
break;
default:
case MessageSeverity.Normal:
msgstyle.normal.textColor = new Color( 1, 1, 1, FADETIME - delta );
break;
}
}
needsRepaint = true;
GUIContent gc = new GUIContent( messages[ i ].ItemMessage );
var sizes = msgstyle.CalcSize( gc );
rect.xMin -= sizes.x - rect.width;
rect.height = sizes.y;
rect.y -= rect.height + 2;
if( messages[ i ].ItemOwnerId < 0 )
{
GUI.Label( rect, gc, msgstyle );
}
else
{
if( GUI.Button( rect, gc, msgstyle ))
{
UIUtils.CurrentWindow.FocusOnNode( messages[ i ].ItemOwnerId, 1, true );
if( Event.current.button == 1 )
{
EditorGUIUtility.systemCopyBuffer = messages[ i ].ItemMessage;
}
}
}
}
}
//GUI.color = cached;
if( needsRepaint )
m_parentWindow.MarkToRepaint();
GUIStyle style = UIUtils.ConsoleLogCircle;
button.size = Vector2.one * 16;
switch( lastCall )
{
case 0:
style.normal.textColor = Color.cyan;
break;
case 1:
style.normal.textColor = Color.yellow;
break;
case 2:
style.normal.textColor = Color.red;
break;
default:
style.normal.textColor = new Color( 1, 1, 1, 0.5f );
break;
}
if( GUI.Button( button, m_boxToggleContent, style ) )
{
maximize = !maximize;
m_parentWindow.MaximizeMessages = maximize;
m_currentScrollPos.y = Mathf.Infinity;
lastCall = -1;
}
style.normal.textColor = new Color( 1, 1, 1, 0.5f );
//GUI.color = cached;
button.x -= button.width + 2;
if( maximize && GUI.Button( button, m_clearContent, style ) )
{
if( messages.Count == 0 )
{
maximize = false;
m_parentWindow.MaximizeMessages = maximize;
}
ClearMessages();
}
button.width += button.width + 2;
bool mouseOnTop = button.Contains( mousePosition );
if( currentEventType == EventType.MouseMove && mouseOnTop )
m_parentWindow.MarkToRepaint();
if( DebugConsoleWindow.DeveloperMode )
{
if( Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Alpha1 )
{
UIUtils.ShowMessage( "This is an info message\nwith two lines" );
}
if( Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Alpha2 )
{
UIUtils.ShowMessage( "This is a warning message", MessageSeverity.Warning );
}
if( Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Alpha3 )
{
UIUtils.ShowMessage( "THIS IS AN ERROR MESSAGE!!", MessageSeverity.Error );
}
}
}
public void ClearMessages()
{
m_parentWindow.Messages.Clear();
m_parentWindow.MaxMsgWidth = 100;
}
public void Toggle()
{
}
public void Destroy()
{
m_parentWindow = null;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ed706353a579cbb46b300406107108b1
timeCreated: 1506345180
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,81 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyShaderEditor
{
public class ContextMenuItem
{
private const string PALETTE_NAME_MOD_STR = " ";
private string m_paletteName;
private string m_name;
private string m_tags;
private string m_category;
private string m_description;
private System.Type m_type;
private GUIContent m_guiContent;
private string m_nameWithShortcut;
private AmplifyShaderFunction m_function;
private NodeAttributes m_nodeAttributes;
public ContextMenuItem( NodeAttributes nodeAttributes, System.Type type, string name, string tags, string category, string description, AmplifyShaderFunction function, KeyCode shortcut )
{
m_nodeAttributes = nodeAttributes;
m_name = name;
m_tags = name + ( string.IsNullOrEmpty( tags ) ? "" : " " + tags );
m_tags = m_tags.ToLower();
m_nameWithShortcut = shortcut != KeyCode.None ? ( name + " [ " + UIUtils.KeyCodeToString( shortcut ) + " ]" ) : name;
m_paletteName = PALETTE_NAME_MOD_STR + m_name;
m_type = type;
m_category = category;
m_description = description;
m_function = function;
m_guiContent = new GUIContent( m_nameWithShortcut, m_description );
}
public int CompareTo( ContextMenuItem item , bool useWeights )
{
if ( useWeights && NodeAttributes.SortOrderPriority > -1 && item.NodeAttributes.SortOrderPriority > -1 )
{
if ( NodeAttributes.SortOrderPriority > item.NodeAttributes.SortOrderPriority )
{
return 1;
}
else if ( NodeAttributes.SortOrderPriority == item.NodeAttributes.SortOrderPriority )
{
return m_name.CompareTo( item.Name );
}
else
{
return -1;
}
}
return m_name.CompareTo( item.Name );
}
public string PaletteName { get { return m_paletteName; } }
public string Name { get { return m_name; } }
public string Tags { get { return m_tags; } }
public string NameWithShortcut { get { return m_nameWithShortcut; } }
public string Category { get { return m_category; } }
public string Description { get { return m_description; } }
public AmplifyShaderFunction Function { get { return m_function; } }
public System.Type NodeType { get { return m_type; } }
public GUIContent ItemUIContent { get { return m_guiContent; } }
public NodeAttributes NodeAttributes { get { return m_nodeAttributes; } }
public override string ToString()
{
return m_name + ":" + m_category + ":" + m_description;
}
public void Destroy()
{
m_guiContent = null;
m_nodeAttributes = null;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 417f409230c530b468b8ab67dd6e3b8b
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,53 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
//using UnityEditor;
//using UnityEngine;
//namespace AmplifyShaderEditor
//{
// //EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector)
// // this might be a bit nonsense since I could use the GetBuiltinSkin directly but this way will bea easier to change to some custom visuals on some near future
// [System.Serializable]
// public class CustomStylesContainer
// {
// public GUIStyle FoldoutStyle
// {
// get { return EditorStyles.foldout; }
// }
// public GUIStyle Label
// {
// get { return GUI.skin.label; }
// }
// public GUIStyle Button
// {
// get { return GUI.skin.button; }
// }
// public GUIStyle TextArea
// {
// get { return GUI.skin.textArea; }
// }
// public GUIStyle Toggle
// {
// get { return GUI.skin.toggle; }
// }
// public GUIStyle Window
// {
// get { return GUI.skin.window; }
// }
// public GUIStyle Textfield
// {
// get { return GUI.skin.textField; }
// }
// public GUIStyle Box
// {
// get { return GUI.skin.box; }
// }
// }
//}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 79d0d783b532b474192b191547bee1c1
timeCreated: 1481126957
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,203 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
//#define ASE_CONSOLE_WINDOW
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
public sealed class DebugConsoleWindow : EditorWindow
{
private const float WindowSizeX = 250;
private const float WindowSizeY = 250;
private const float WindowPosX = 5;
private const float WindowPosY = 5;
private Rect m_availableArea;
private bool m_wikiAreaFoldout = true;
private bool m_miscAreaFoldout = true;
private Vector2 m_currentScrollPos;
private int m_minURLNode = 0;
private int m_maxURLNode = -1;
#if ASE_CONSOLE_WINDOW
public readonly static bool DeveloperMode = true;
public static bool UseShaderPanelsInfo = true;
[MenuItem( "Window/Amplify Shader Editor/Open Debug Console" )]
static void OpenMainShaderGraph()
{
OpenWindow();
}
[MenuItem( "Window/Amplify Shader Editor/Create Template Menu Items" )]
public static void CreateTemplateMenuItems()
{
UIUtils.CurrentWindow.TemplatesManagerInstance.CreateTemplateMenuItems();
}
#else
public readonly static bool DeveloperMode = false;
public static bool UseShaderPanelsInfo = false;
#endif
public static DebugConsoleWindow OpenWindow()
{
if ( DeveloperMode )
{
DebugConsoleWindow currentWindow = ( DebugConsoleWindow ) DebugConsoleWindow.GetWindow( typeof( DebugConsoleWindow ), false, "ASE Debug Console" );
currentWindow.titleContent.tooltip = "Debug Options for ASE. Intented only for ASE development team";
currentWindow.minSize = new Vector2( WindowSizeX, WindowSizeY );
currentWindow.maxSize = new Vector2( WindowSizeX, 2 * WindowSizeY ); ;
currentWindow.wantsMouseMove = true;
return currentWindow;
}
return null;
}
void OnGUI()
{
m_availableArea = new Rect( WindowPosX, WindowPosY, position.width - 2 * WindowPosX, position.height - 2 * WindowPosY );
GUILayout.BeginArea( m_availableArea );
{
m_currentScrollPos = EditorGUILayout.BeginScrollView( m_currentScrollPos, GUILayout.Width( 0 ), GUILayout.Height( 0 ) );
{
EditorGUILayout.BeginVertical();
{
AmplifyShaderEditorWindow window = UIUtils.CurrentWindow;
if ( window != null )
{
EditorGUILayout.Separator();
NodeUtils.DrawPropertyGroup( ref m_wikiAreaFoldout, "Wiki Helper", ShowWikiHelperFunctions );
EditorGUILayout.Separator();
NodeUtils.DrawPropertyGroup( ref m_miscAreaFoldout, "Misc", ShowMiscFuntions );
EditorGUILayout.Separator();
}
else
{
EditorGUILayout.LabelField( "Please open an ASE window to access debug options" );
}
}
EditorGUILayout.EndVertical();
}
EditorGUILayout.EndScrollView();
}
GUILayout.EndArea();
}
void ShowWikiHelperFunctions()
{
AmplifyShaderEditorWindow window = UIUtils.CurrentWindow;
EditorGUILayout.Separator();
if ( GUILayout.Button( "Nodes Screen Shots" ) )
{
window.CurrentNodeExporterUtils.ActivateAutoScreenShot( Application.dataPath + "/../NodesInfo/Shots/",0,-1 );
}
GUILayout.BeginHorizontal();
if( GUILayout.Button( "Nodes URLs" ) )
{
window.CurrentNodeExporterUtils.ActivateNodesURL( m_minURLNode, m_maxURLNode );
}
m_minURLNode = EditorGUILayout.IntField( m_minURLNode );
m_maxURLNode = EditorGUILayout.IntField( m_maxURLNode );
GUILayout.EndHorizontal();
EditorGUILayout.Separator();
if( GUILayout.Button( "Nodes Undo Test" ) )
{
window.CurrentNodeExporterUtils.ActivateAutoUndo();
}
EditorGUILayout.Separator();
if ( GUILayout.Button( "Nodes Info" ) )
{
window.CurrentPaletteWindow.DumpAvailableNodes( false, Application.dataPath + "/../NodesInfo/" );
window.CurrentPaletteWindow.DumpAvailableNodes( true, Application.dataPath + "/../NodesInfo/" );
}
EditorGUILayout.Separator();
if ( GUILayout.Button( "Shortcuts Info" ) )
{
window.ShortcutManagerInstance.DumpShortcutsToDisk( Application.dataPath + "/../NodesInfo/" );
}
}
void ShowMiscFuntions()
{
AmplifyShaderEditorWindow window = UIUtils.CurrentWindow;
if ( GUILayout.Button( "Force Example Shader Compilation" ) )
{
UIUtils.ForceExampleShaderCompilation();
}
EditorGUILayout.Separator();
if ( GUILayout.Button( "Refresh Available Nodes" ) )
{
window.RefreshAvaibleNodes();
}
EditorGUILayout.Separator();
if ( GUILayout.Button( "Dump Uniform Names" ) )
{
//window.CurrentPaletteWindow.NewList()
window.DuplicatePrevBufferInstance.DumpUniformNames();
}
EditorGUILayout.Separator();
if ( GUILayout.Button( "Force Palette Update" ) )
{
Debug.Log( UIUtils.CurrentWindow.IsShaderFunctionWindow );
window.CurrentPaletteWindow.ForceUpdate = true;
}
EditorGUILayout.Separator();
if( GUILayout.Button( "Detect Infinite Loops" ) )
{
if( window.IsShaderFunctionWindow )
{
Debug.Log( "Starting infinite loop detection over shader functions" );
List<FunctionOutput> nodes = window.OutsideGraph.FunctionOutputNodes.NodesList;
for( int i = 0; i < nodes.Count; i++ )
{
UIUtils.DetectNodeLoopsFrom( nodes[ i ], new Dictionary<int, int>() );
}
}
else
{
if( window.OutsideGraph.MultiPassMasterNodes.Count > 0 )
{
Debug.Log( "Starting infinite loop detection over shader from template" );
List<TemplateMultiPassMasterNode> nodes = window.OutsideGraph.MultiPassMasterNodes.NodesList;
for( int i = 0; i < nodes.Count; i++ )
{
UIUtils.DetectNodeLoopsFrom( nodes[ i ], new Dictionary<int, int>() );
}
}
else
{
Debug.Log( "Starting infinite loop detection over standard shader" );
UIUtils.DetectNodeLoopsFrom( window.OutsideGraph.CurrentMasterNode, new Dictionary<int, int>() );
}
}
Debug.Log( "End infinite loop detection" );
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 52308890136cd7746a5a073c9be8f028
timeCreated: 1487850100
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,47 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEditor;
using UnityEngine;
namespace AmplifyShaderEditor
{
public class DragAndDropTool
{
public delegate void OnValidDropObject(params UnityEngine.Object[] draggedObjs );
public event OnValidDropObject OnValidDropObjectEvt;
public void Destroy()
{
OnValidDropObjectEvt = null;
}
public void TestDragAndDrop( Rect dropArea )
{
Event currentEvent = Event.current;
EventType currentEventType = currentEvent.type;
switch (currentEventType)
{
case EventType.DragUpdated:
case EventType.DragPerform:
{
if (!dropArea.Contains(currentEvent.mousePosition))
return;
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
if (currentEvent.type == EventType.DragPerform)
{
DragAndDrop.AcceptDrag();
if (OnValidDropObjectEvt != null)
{
OnValidDropObjectEvt(DragAndDrop.objectReferences);
}
}
}break;
case EventType.DragExited:DragAndDrop.PrepareStartDrag();break;
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 41c9bd09aea1377459c7e62910711c22
timeCreated: 1481126955
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,375 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections.Generic;
using UnityEngine;
namespace AmplifyShaderEditor
{
[Serializable]
public class DuplicatePreventionBuffer
{
private const string VectorNameStr = "Vector ";
private const string TextureSampleNameStr = "Texture Sample ";
private const string MatrixNameStr = "Matrix ";
private const string IntNameStr = "Int ";
private const string FloatNameStr = "Float ";
private const string ColorNameStr = "Color ";
[SerializeField]
private int[] m_availableUVChannelsArray = { -1, -1, -1, -1 };
private string[] m_availableUVChannelsNamesArray = { "null",
"null",
"null",
"null" };
private Dictionary<string, int> m_availablePropertyNames = new Dictionary<string, int>();
private Dictionary<string, int> m_availableUniformNames = new Dictionary<string, int>();
private Dictionary<string, int> m_availableLocalVariableNames = new Dictionary<string, int>();
public void ReleaseAllUVChannels()
{
for ( int i = 0; i < m_availableUVChannelsArray.Length; i++ )
{
m_availableUVChannelsArray[ i ] = -1;
}
}
public bool RegisterUVChannel( int nodeId, int channelId, string name )
{
if ( channelId < 0 ||
channelId > ( m_availableUVChannelsArray.Length - 1 ) ||
m_availableUVChannelsArray[ channelId ] >= 0 )
{
return false;
}
m_availableUVChannelsArray[ channelId ] = nodeId;
m_availableUVChannelsNamesArray[ channelId ] = name;
return true;
}
public bool ReleaseUVChannel( int nodeId, int channelId )
{
if ( channelId < 0 ||
channelId > ( m_availableUVChannelsArray.Length - 1 ) )
{
return false;
}
if ( m_availableUVChannelsArray[ channelId ] == nodeId )
{
m_availableUVChannelsArray[ channelId ] = -1;
return true;
}
return false;
}
public int RegisterFirstAvailableChannel( int nodeId , string name)
{
for ( int i = 0; i < m_availableUVChannelsArray.Length; i++ )
{
if ( m_availableUVChannelsArray[ i ] == -1 )
{
m_availableUVChannelsArray[ i ] = nodeId;
m_availableUVChannelsNamesArray[ i ] = name;
return i;
}
}
return -1;
}
public bool IsChannelAvailable( int channelId )
{
if ( channelId < 0 ||
channelId > ( m_availableUVChannelsArray.Length - 1 ) )
{
return false;
}
return ( m_availableUVChannelsArray[ channelId ] < 0 );
}
public int GetFirstOccupiedChannel()
{
for ( int i = 0; i < 4; i++ )
{
if ( m_availableUVChannelsArray[ i ] > -1 )
return i;
}
return -1;
}
public string GetChannelName( int channelId )
{
if ( channelId < 0 ||
channelId > ( m_availableUVChannelsArray.Length - 1 ) )
{
return string.Empty;
}
return m_availableUVChannelsNamesArray[ channelId ] ;
}
public void SetChannelName( int channelId , string name )
{
if ( channelId < 0 ||
channelId > ( m_availableUVChannelsArray.Length - 1 ) )
{
return;
}
m_availableUVChannelsNamesArray[ channelId ] = name;
}
public bool RegisterLocalVariableName( int nodeId, string name )
{
if ( name.Length == 0 )
return false;
if ( m_availableLocalVariableNames.ContainsKey( name ) )
{
if ( m_availableLocalVariableNames[ name ] > -1 )
{
return false;
}
else
{
m_availableLocalVariableNames[ name ] = nodeId;
return true;
}
}
m_availableLocalVariableNames.Add( name, nodeId );
return true;
}
public int CheckUniformNameOwner( string name )
{
if ( name.Length == 0 )
return -1;
if ( m_availableUniformNames.ContainsKey( name ) )
{
return m_availableUniformNames[ name ];
}
return -1;
}
public bool RegisterUniformName( int nodeId, string name )
{
if ( name.Length == 0 )
return false;
if ( m_availableUniformNames.ContainsKey( name ) )
{
if ( m_availableUniformNames[ name ] > -1 )
{
return false;
}
else
{
m_availableUniformNames[ name ] = nodeId;
return true;
}
}
m_availableUniformNames.Add( name, nodeId );
return true;
}
public void DumpUniformNames()
{
string val = "CONTENTS\n";
foreach ( KeyValuePair<string, int> kvp in m_availableUniformNames )
{
val += ( "key " + kvp.Key + " : value " + kvp.Value + "\n" );
}
}
public void DumpLocalVariableNames()
{
string val = "CONTENTS\n";
foreach ( KeyValuePair<string, int> kvp in m_availableLocalVariableNames )
{
val += ( "key " + kvp.Key + " : value " + kvp.Value + "\n" );
}
}
public bool ReleaseUniformName( int nodeId, string name )
{
if ( !string.IsNullOrEmpty(name) && name.Length == 0 )
return false;
if ( m_availableUniformNames.ContainsKey( name ) )
{
if ( m_availableUniformNames[ name ] == nodeId )
{
m_availableUniformNames.Remove( name );
return true;
}
}
return false;
}
public bool ReleaseLocalVariableName( int nodeId, string name )
{
if ( name.Length == 0 )
return false;
if ( m_availableLocalVariableNames.ContainsKey( name ) )
{
if ( m_availableLocalVariableNames[ name ] == nodeId )
{
m_availableLocalVariableNames.Remove( name );
return true;
}
}
return false;
}
public void ReleaseAllUniformNames()
{
m_availableUniformNames.Clear();
}
public void ReleaseAllLocalVariableNames()
{
m_availableLocalVariableNames.Clear();
}
public void GetFirstAvailableName( int nodeId, WirePortDataType type , out string outProperty , out string outInspector, bool useCustomPrefix = false, string customPrefix = null)
{
string name = string.Empty;
if ( useCustomPrefix && customPrefix != null )
{
name = customPrefix;
}
else
{
switch ( type )
{
case WirePortDataType.OBJECT:
case WirePortDataType.FLOAT:
{
name = FloatNameStr;
}
break;
case WirePortDataType.INT:
{
name = IntNameStr;
}
break;
case WirePortDataType.FLOAT2:
case WirePortDataType.FLOAT3:
case WirePortDataType.FLOAT4:
{
name = VectorNameStr;
}
break;
case WirePortDataType.FLOAT3x3:
case WirePortDataType.FLOAT4x4:
{
name = MatrixNameStr;
}
break;
case WirePortDataType.COLOR:
{
name = ColorNameStr;
}
break;
}
}
int count = 0;
bool foundName = false;
while ( !foundName )
{
string inspectorName = name + count;
string propertyName = UIUtils.GeneratePropertyName( inspectorName , PropertyType.Property );
if ( IsUniformNameAvailable( propertyName ) )
{
outInspector = inspectorName;
outProperty = propertyName;
RegisterUniformName( nodeId, propertyName );
return;
}
count += 1;
}
outProperty = string.Empty;
outInspector = string.Empty;
UIUtils.ShowMessage( "Could not find a valid name " + MessageSeverity.Warning );
}
public bool IsUniformNameAvailable( string name )
{
if ( m_availableUniformNames.ContainsKey( name ) && m_availableUniformNames[ name ] > -1 )
return false;
return true;
}
public bool IsLocalvariableNameAvailable( string name )
{
if ( m_availableLocalVariableNames.ContainsKey( name ) && m_availableLocalVariableNames[ name ] > -1 )
return false;
return true;
}
public bool GetPropertyName( int nodeId, string name )
{
if ( m_availablePropertyNames.ContainsKey( name ) )
{
if ( m_availablePropertyNames[ name ] > -1 )
{
return false;
}
else
{
m_availablePropertyNames[ name ] = nodeId;
return true;
}
}
m_availablePropertyNames.Add( name, nodeId );
return true;
}
public bool ReleasePropertyName( int nodeId, string name )
{
if ( m_availablePropertyNames.ContainsKey( name ) )
{
if ( m_availablePropertyNames[ name ] == nodeId )
{
m_availablePropertyNames[ name ] = -1;
return true;
}
}
return false;
}
public void ReleaseAllPropertyNames()
{
m_availablePropertyNames.Clear();
}
public bool IsPropertyNameAvailable( string name )
{
if ( m_availablePropertyNames.ContainsKey( name ) && m_availablePropertyNames[ name ] > -1 )
return false;
return true;
}
public void ReleaseAllData()
{
ReleaseAllUVChannels();
ReleaseAllUniformNames();
ReleaseAllPropertyNames();
ReleaseAllLocalVariableNames();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a4cfbb4204c63ca4e8f7cec73f6b3ef8
timeCreated: 1481126958
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,393 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
namespace AmplifyShaderEditor
{
public class ShortcutKeyData
{
public bool IsPressed;
public System.Type NodeType;
public string Name;
public ShortcutKeyData( System.Type type, string name )
{
NodeType = type;
Name = name;
IsPressed = false;
}
}
public class GraphContextMenu
{
private List<ContextMenuItem> m_items;
private List<ContextMenuItem> m_itemFunctions;
private Dictionary<System.Type, NodeAttributes> m_itemsDict;
private Dictionary<System.Type, NodeAttributes> m_deprecatedItemsDict;
private Dictionary<System.Type, System.Type> m_castTypes;
private Dictionary<KeyCode, ShortcutKeyData> m_shortcutTypes;
private KeyCode m_lastKeyPressed;
private ParentGraph m_currentGraph;
private bool m_correctlyLoaded = false;
public GraphContextMenu( ParentGraph currentGraph )
{
m_currentGraph = currentGraph;
m_correctlyLoaded = RefreshNodes( currentGraph );
}
private Type[] GetTypesInNamespace( Assembly assembly, string nameSpace )
{
return assembly.GetTypes().Where( t => String.Equals( t.Namespace, nameSpace, StringComparison.Ordinal ) ).ToArray();
}
public bool RefreshNodes( ParentGraph currentGraph )
{
if( m_items != null )
{
m_items.Clear();
m_items = null;
}
if( m_itemFunctions != null )
{
m_itemFunctions.Clear();
m_itemFunctions = null;
}
m_items = new List<ContextMenuItem>();
m_itemFunctions = new List<ContextMenuItem>();
if( m_itemsDict != null )
m_itemsDict.Clear();
m_itemsDict = new Dictionary<System.Type, NodeAttributes>();
if( m_deprecatedItemsDict != null )
m_deprecatedItemsDict.Clear();
m_deprecatedItemsDict = new Dictionary<System.Type, NodeAttributes>();
if( m_castTypes != null )
m_castTypes.Clear();
m_castTypes = new Dictionary<System.Type, System.Type>();
if( m_shortcutTypes != null )
m_shortcutTypes.Clear();
m_shortcutTypes = new Dictionary<KeyCode, ShortcutKeyData>();
m_lastKeyPressed = KeyCode.None;
// Fetch all available nodes by their attributes
try
{
//IEnumerable<System.Type> availableTypes = AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany( type => type.GetTypes() );
var mainAssembly = Assembly.GetExecutingAssembly();
Type[] availableTypes = GetTypesInNamespace( mainAssembly, "AmplifyShaderEditor" );
#if UNITY_2017_3_OR_NEWER
try
{
var editorAssembly = Assembly.Load( "Assembly-CSharp-Editor" );
if( mainAssembly != editorAssembly )
{
Type[] extraTypes = GetTypesInNamespace( editorAssembly, "AmplifyShaderEditor" );
availableTypes = availableTypes.Concat<Type>( extraTypes ).ToArray();
}
}
catch( Exception )
{
// quiet catch because we don't care if it fails to find the assembly, we'll just skip it
}
#endif
foreach( System.Type type in availableTypes )
{
foreach( NodeAttributes attribute in Attribute.GetCustomAttributes( type ).OfType<NodeAttributes>() )
{
if( attribute.Available && !attribute.Deprecated )
{
//if ( !UIUtils.CurrentWindow.IsShaderFunctionWindow && attribute.AvailableInFunctionsOnly )
// continue;
if( !UIUtils.HasColorCategory( attribute.Category ) )
{
if( !String.IsNullOrEmpty( attribute.CustomCategoryColor ) )
{
try
{
Color color = new Color();
ColorUtility.TryParseHtmlString( attribute.CustomCategoryColor, out color );
UIUtils.AddColorCategory( attribute.Category, color );
}
catch( Exception e )
{
Debug.LogException( e );
UIUtils.AddColorCategory( attribute.Category, Constants.DefaultCategoryColor );
}
}
//else
//{
// UIUtils.AddColorCategory( attribute.Category, Constants.DefaultCategoryColor );
//}
}
if( attribute.CastType != null && attribute.CastType.Length > 0 && type != null )
{
for( int i = 0; i < attribute.CastType.Length; i++ )
{
m_castTypes.Add( attribute.CastType[ i ], type );
}
}
if( attribute.ShortcutKey != KeyCode.None && type != null )
m_shortcutTypes.Add( attribute.ShortcutKey, new ShortcutKeyData( type, attribute.Name ) );
ContextMenuItem newItem = new ContextMenuItem( attribute, type, attribute.Name, attribute.Tags, attribute.Category, attribute.Description, null, attribute.ShortcutKey );
if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, NodeAvailability.SurfaceShader ) )
m_items.Add( newItem );
else if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, currentGraph.ParentWindow.CurrentNodeAvailability ) )
m_items.Add( newItem );
else if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, currentGraph.CurrentCanvasMode ) )
m_items.Add( newItem );
m_itemsDict.Add( type, attribute );
m_itemFunctions.Add( newItem );
}
else
{
m_deprecatedItemsDict.Add( type, attribute );
}
}
}
}
catch( ReflectionTypeLoadException exception )
{
Debug.LogException( exception );
return false;
}
string[] guids = AssetDatabase.FindAssets( "t:AmplifyShaderFunction" );
List<AmplifyShaderFunction> allFunctions = new List<AmplifyShaderFunction>();
for( int i = 0; i < guids.Length; i++ )
{
allFunctions.Add( AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( AssetDatabase.GUIDToAssetPath( guids[ i ] ) ) );
}
int functionCount = allFunctions.Count;
if( functionCount > 0 )
{
m_castTypes.Add( typeof( AmplifyShaderFunction ), typeof( FunctionNode ) );
}
for( int i = 0; i < functionCount; i++ )
{
if( !allFunctions[ i ].Hidden )
{
NodeAttributes attribute = new NodeAttributes( allFunctions[ i ].FunctionName, allFunctions[ i ].CustomNodeCategory, allFunctions[ i ].Description, KeyCode.None, true, 0, int.MaxValue, typeof( AmplifyShaderFunction ) );
System.Type type = typeof( FunctionNode );
ContextMenuItem newItem = new ContextMenuItem( attribute, type, AddSpacesToSentence( attribute.Name ), attribute.Tags, attribute.Category, attribute.Description, allFunctions[ i ], attribute.ShortcutKey );
m_items.Add( newItem );
m_itemFunctions.Add( newItem );
}
}
//Sort out the final list by name
m_items.Sort( ( x, y ) => x.Category.CompareTo( y.Category ) );
m_itemFunctions.Sort( ( x, y ) => x.Category.CompareTo( y.Category ) );
return true;
}
public void Destroy()
{
for( int i = 0; i < m_items.Count; i++ )
{
m_items[ i ].Destroy();
}
for( int i = 0; i < m_itemFunctions.Count; i++ )
{
if( m_itemFunctions[ i ] != null )
m_itemFunctions[ i ].Destroy();
}
m_items.Clear();
m_items = null;
m_itemFunctions.Clear();
m_itemFunctions = null;
m_itemsDict.Clear();
m_itemsDict = null;
m_deprecatedItemsDict.Clear();
m_deprecatedItemsDict = null;
m_castTypes.Clear();
m_castTypes = null;
m_shortcutTypes.Clear();
m_shortcutTypes = null;
}
public static string AddSpacesToSentence( string text )
{
if( string.IsNullOrEmpty( text ) )
return string.Empty;
bool lastIsUpper = char.IsUpper( text, 0 );
bool lastIsLetter = char.IsLetter( text, 0 );
StringBuilder title = new StringBuilder();
title.Append( text[ 0 ] );
for( int i = 1; i < text.Length; i++ )
{
bool currIsUpper = char.IsUpper( text, i );
bool currIsLetter = char.IsLetter( text, i );
if( currIsUpper && !lastIsUpper && lastIsLetter )
{
title.Append( " " );
}
// if current is a number and previous is a letter we space it (ie: Rotation2D = Rotation 2D)
if( lastIsLetter && char.IsNumber( text, i ) )
{
title.Append( " " );
}
// if previous is upper, current is upper and the next two following are lower then we space it (ie: UVDistortion = UV Distortion)
if( i < text.Length - 1 )
{
bool nextIsLower = char.IsLower( text, i + 1 ) && char.IsLetter( text, i + 1 );
bool lastIsLower = i < text.Length - 2 ? char.IsLower( text, i + 2 ) && char.IsLetter( text, i + 2 ) : false;
if( lastIsUpper && currIsUpper && currIsLetter && nextIsLower && lastIsLower )
{
title.Append( " " );
}
}
lastIsUpper = currIsUpper;
lastIsLetter = currIsLetter;
title.Append( text[ i ] );
}
return title.ToString();
}
public NodeAttributes GetNodeAttributesForType( System.Type type )
{
if( type == null )
{
Debug.LogError( "Invalid type detected" );
return null;
}
if( m_itemsDict.ContainsKey( type ) )
return m_itemsDict[ type ];
return null;
}
public NodeAttributes GetDeprecatedNodeAttributesForType( System.Type type )
{
if( m_deprecatedItemsDict.ContainsKey( type ) )
return m_deprecatedItemsDict[ type ];
return null;
}
public void UpdateKeyPress( KeyCode key )
{
if( key == KeyCode.None )
return;
m_lastKeyPressed = key;
if( m_shortcutTypes.ContainsKey( key ) )
{
m_shortcutTypes[ key ].IsPressed = true;
}
}
public void UpdateKeyReleased( KeyCode key )
{
if( key == KeyCode.None )
return;
if( m_shortcutTypes.ContainsKey( key ) )
{
m_shortcutTypes[ key ].IsPressed = false;
}
}
public void ResetShortcutKeyStates()
{
foreach( KeyValuePair<KeyCode, ShortcutKeyData> kvp in m_shortcutTypes )
{
kvp.Value.IsPressed = false;
}
}
public ParentNode CreateNodeFromCastType( System.Type type )
{
if( m_castTypes.ContainsKey( type ) )
{
ParentNode newNode = (ParentNode)ScriptableObject.CreateInstance( m_castTypes[ type ] );
return newNode;
}
return null;
}
public ParentNode CreateNodeFromShortcutKey()
{
if( m_lastKeyPressed == KeyCode.None )
return null;
if( m_shortcutTypes.ContainsKey( m_lastKeyPressed ) && m_shortcutTypes[ m_lastKeyPressed ].IsPressed )
{
ParentNode newNode = (ParentNode)ScriptableObject.CreateInstance( m_shortcutTypes[ m_lastKeyPressed ].NodeType );
return newNode;
}
return null;
}
public bool CheckShortcutKey()
{
if( m_lastKeyPressed == KeyCode.None )
return false;
if( m_shortcutTypes.ContainsKey( m_lastKeyPressed ) && m_shortcutTypes[ m_lastKeyPressed ].IsPressed )
{
return true;
}
return false;
}
public List<ContextMenuItem> MenuItems
{
get
{
if( m_currentGraph.ParentWindow.IsShaderFunctionWindow )
return m_itemFunctions;
else
return m_items;
}
}
public List<ContextMenuItem> ItemFunctions { get { return m_itemFunctions; } }
public KeyCode LastKeyPressed
{
get { return m_lastKeyPressed; }
}
public Dictionary<KeyCode, ShortcutKeyData> NodeShortcuts { get { return m_shortcutTypes; } }
public bool CorrectlyLoaded { get { return m_correctlyLoaded; } }
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5c34fc95a1ddd7d42bc74151061035f4
timeCreated: 1481126956
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,451 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
namespace AmplifyShaderEditor
{
public enum MenuAnchor
{
TOP_LEFT = 0,
TOP_CENTER,
TOP_RIGHT,
MIDDLE_LEFT,
MIDDLE_CENTER,
MIDDLE_RIGHT,
BOTTOM_LEFT,
BOTTOM_CENTER,
BOTTOM_RIGHT,
NONE
}
public enum MenuAutoSize
{
MATCH_VERTICAL = 0,
MATCH_HORIZONTAL,
NONE
}
public class MenuParent
{
protected AmplifyShaderEditorWindow m_parentWindow = null;
protected const float MinimizeButtonXSpacing = 5;
protected const float MinimizeButtonYSpacing = 5.5f;
protected const float ResizeAreaWidth = 5;
protected const float MinimizeCollisionAdjust = 5;
protected GUIStyle m_style;
protected GUIContent m_content;
protected Rect m_maximizedArea;
protected Rect m_transformedArea;
protected Rect m_resizeArea;
protected MenuAnchor m_anchor;
protected MenuAutoSize m_autoSize;
protected bool m_isActive = true;
protected bool m_isMaximized = true;
protected bool m_lockOnMinimize = false;
protected bool m_preLockState = false;
protected Rect m_minimizedArea;
protected Rect m_minimizeButtonPos;
protected float m_realWidth;
protected GUIStyle m_empty = new GUIStyle();
protected float m_resizeDelta;
protected bool m_isResizing = false;
protected bool m_resizable = false;
protected GUIStyle m_resizeAreaStyle;
protected bool m_isMouseInside = false;
protected Vector2 m_currentScrollPos;
public MenuParent( AmplifyShaderEditorWindow parentWindow, float x, float y, float width, float height, string name, MenuAnchor anchor = MenuAnchor.NONE, MenuAutoSize autoSize = MenuAutoSize.NONE )
{
m_parentWindow = parentWindow;
m_anchor = anchor;
m_autoSize = autoSize;
m_maximizedArea = new Rect( x, y, width, height );
m_content = new GUIContent( GUIContent.none );
m_content.text = name;
m_transformedArea = new Rect();
m_resizeArea = new Rect();
m_resizeArea.width = ResizeAreaWidth;
m_resizeAreaStyle = GUIStyle.none;
m_currentScrollPos = Vector2.zero;
}
public void SetMinimizedArea( float x, float y, float width, float height )
{
m_minimizedArea = new Rect( x, y, width, height );
}
protected void InitDraw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId )
{
if ( m_style == null )
{
m_style = new GUIStyle( UIUtils.TextArea );
#if UNITY_2019_3_OR_NEWER
m_style.normal.background = m_style.normal.scaledBackgrounds[ 0 ];
m_style.normal.scaledBackgrounds = null;
m_style.border = new RectOffset( 4, 4, 4, 4 );
#endif
m_style.stretchHeight = true;
m_style.stretchWidth = true;
m_style.fontSize = ( int ) Constants.DefaultTitleFontSize;
m_style.fontStyle = FontStyle.Normal;
Texture minimizeTex = UIUtils.GetCustomStyle( CustomStyle.MaximizeButton ).normal.background;
m_minimizeButtonPos = new Rect( 0, 0, minimizeTex.width, minimizeTex.height );
}
Rect currentArea = m_isMaximized ? m_maximizedArea : m_minimizedArea;
if ( m_isMaximized )
{
if ( m_resizable )
{
if ( m_isResizing )
{
if ( m_anchor == MenuAnchor.TOP_LEFT )
m_resizeDelta = ( ParentWindow.CurrentEvent.mousePosition.x - m_maximizedArea.width );
else if ( m_anchor == MenuAnchor.TOP_RIGHT )
m_resizeDelta = ParentWindow.CurrentEvent.mousePosition.x - ( parentPosition.width - m_maximizedArea.width);
}
}
m_realWidth = m_maximizedArea.width;
if ( m_resizable )
{
if ( m_anchor == MenuAnchor.TOP_LEFT )
{
currentArea.width += m_resizeDelta;
m_realWidth += m_resizeDelta;
}
else if ( m_anchor == MenuAnchor.TOP_RIGHT )
{
currentArea.width -= m_resizeDelta;
m_realWidth -= m_resizeDelta;
}
}
}
else
{
if ( currentArea.x < 0 )
{
m_realWidth = currentArea.width + currentArea.x;
}
else if ( ( currentArea.x + currentArea.width ) > parentPosition.width )
{
m_realWidth = parentPosition.width - currentArea.x;
}
if ( m_realWidth < 0 )
m_realWidth = 0;
}
switch ( m_anchor )
{
case MenuAnchor.TOP_LEFT:
{
m_transformedArea.x = currentArea.x;
m_transformedArea.y = currentArea.y;
if ( m_isMaximized )
{
m_minimizeButtonPos.x = m_transformedArea.x + m_transformedArea.width - m_minimizeButtonPos.width - MinimizeButtonXSpacing;
m_minimizeButtonPos.y = m_transformedArea.y + MinimizeButtonYSpacing;
m_resizeArea.x = m_transformedArea.x + m_transformedArea.width;
m_resizeArea.y = m_minimizeButtonPos.y;
m_resizeArea.height = m_transformedArea.height;
}
else
{
float width = ( m_transformedArea.width - m_transformedArea.x );
m_minimizeButtonPos.x = m_transformedArea.x + width * 0.5f - m_minimizeButtonPos.width * 0.5f;
m_minimizeButtonPos.y = m_transformedArea.height * 0.5f - m_minimizeButtonPos.height * 0.5f;
}
}
break;
case MenuAnchor.TOP_CENTER:
{
m_transformedArea.x = parentPosition.width * 0.5f + currentArea.x;
m_transformedArea.y = currentArea.y;
}
break;
case MenuAnchor.TOP_RIGHT:
{
m_transformedArea.x = parentPosition.width - currentArea.x - currentArea.width;
m_transformedArea.y = currentArea.y;
if ( m_isMaximized )
{
m_minimizeButtonPos.x = m_transformedArea.x + MinimizeButtonXSpacing;
m_minimizeButtonPos.y = m_transformedArea.y + MinimizeButtonYSpacing;
m_resizeArea.x = m_transformedArea.x - ResizeAreaWidth;
m_resizeArea.y = m_minimizeButtonPos.y;
m_resizeArea.height = m_transformedArea.height;
}
else
{
float width = ( parentPosition.width - m_transformedArea.x );
m_minimizeButtonPos.x = m_transformedArea.x + width * 0.5f - m_minimizeButtonPos.width * 0.5f;
m_minimizeButtonPos.y = m_transformedArea.height * 0.5f - m_minimizeButtonPos.height * 0.5f;
}
}
break;
case MenuAnchor.MIDDLE_LEFT:
{
m_transformedArea.x = currentArea.x;
m_transformedArea.y = parentPosition.height * 0.5f + currentArea.y;
}
break;
case MenuAnchor.MIDDLE_CENTER:
{
m_transformedArea.x = parentPosition.width * 0.5f + currentArea.x;
m_transformedArea.y = parentPosition.height * 0.5f + currentArea.y;
}
break;
case MenuAnchor.MIDDLE_RIGHT:
{
m_transformedArea.x = parentPosition.width - currentArea.x - currentArea.width;
m_transformedArea.y = parentPosition.height * 0.5f + currentArea.y;
}
break;
case MenuAnchor.BOTTOM_LEFT:
{
m_transformedArea.x = currentArea.x;
m_transformedArea.y = parentPosition.height - currentArea.y - currentArea.height;
}
break;
case MenuAnchor.BOTTOM_CENTER:
{
m_transformedArea.x = parentPosition.width * 0.5f + currentArea.x;
m_transformedArea.y = parentPosition.height - currentArea.y - currentArea.height;
}
break;
case MenuAnchor.BOTTOM_RIGHT:
{
m_transformedArea.x = parentPosition.width - currentArea.x - currentArea.width;
m_transformedArea.y = parentPosition.height - currentArea.y - currentArea.height;
}
break;
case MenuAnchor.NONE:
{
m_transformedArea.x = currentArea.x;
m_transformedArea.y = currentArea.y;
}
break;
}
switch ( m_autoSize )
{
case MenuAutoSize.MATCH_HORIZONTAL:
{
m_transformedArea.width = parentPosition.width - m_transformedArea.x;
m_transformedArea.height = currentArea.height;
}
break;
case MenuAutoSize.MATCH_VERTICAL:
{
m_transformedArea.width = currentArea.width;
m_transformedArea.height = parentPosition.height - m_transformedArea.y;
}
break;
case MenuAutoSize.NONE:
{
m_transformedArea.width = currentArea.width;
m_transformedArea.height = currentArea.height;
}
break;
}
}
public virtual void Draw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus )
{
InitDraw( parentPosition, mousePosition, mouseButtonId );
if ( ParentWindow.CurrentEvent.type == EventType.MouseDrag && ParentWindow.CurrentEvent.button > 0 /*catches both middle and right mouse button*/ )
{
m_isMouseInside = IsInside( mousePosition );
if ( m_isMouseInside )
{
m_currentScrollPos.x += Constants.MenuDragSpeed * ParentWindow.CurrentEvent.delta.x;
if ( m_currentScrollPos.x < 0 )
m_currentScrollPos.x = 0;
m_currentScrollPos.y += Constants.MenuDragSpeed * ParentWindow.CurrentEvent.delta.y;
if ( m_currentScrollPos.y < 0 )
m_currentScrollPos.y = 0;
}
}
}
public void PostDraw()
{
if ( !m_isMaximized )
{
m_transformedArea.height = 35;
GUI.Label( m_transformedArea, m_content, m_style );
}
Color colorBuffer = GUI.color;
GUI.color = EditorGUIUtility.isProSkin ? Color.white : Color.black;
bool guiEnabledBuffer = GUI.enabled;
GUI.enabled = !m_lockOnMinimize;
Rect buttonArea = m_minimizeButtonPos;
buttonArea.x -= MinimizeCollisionAdjust;
buttonArea.width += 2 * MinimizeCollisionAdjust;
buttonArea.y -= MinimizeCollisionAdjust;
buttonArea.height += 2 * MinimizeCollisionAdjust;
if ( m_parentWindow.CameraDrawInfo.CurrentEventType == EventType.Repaint )
GUI.Label( m_minimizeButtonPos, string.Empty, UIUtils.GetCustomStyle( m_isMaximized ? CustomStyle.MinimizeButton : CustomStyle.MaximizeButton ) );
if( m_parentWindow.CameraDrawInfo.CurrentEventType == EventType.MouseDown && buttonArea.Contains( m_parentWindow.CameraDrawInfo.MousePosition ) )
//if ( GUI.Button( buttonArea, string.Empty, m_empty ) )
{
m_isMaximized = !m_isMaximized;
m_resizeDelta = 0;
}
if ( m_resizable && m_isMaximized )
{
EditorGUIUtility.AddCursorRect( m_resizeArea, MouseCursor.ResizeHorizontal );
if ( !m_isResizing && GUI.RepeatButton( m_resizeArea, string.Empty, m_resizeAreaStyle ) )
{
m_isResizing = true;
}
else
{
if ( m_isResizing )
{
if ( ParentWindow.CurrentEvent.isMouse && ParentWindow.CurrentEvent.type != EventType.MouseDrag )
{
m_isResizing = false;
}
}
}
if ( m_realWidth < buttonArea.width )
{
// Auto-minimize
m_isMaximized = false;
m_resizeDelta = 0;
m_isResizing = false;
}
else
{
float halfSizeWindow = 0.5f * ParentWindow.position.width;
if ( m_realWidth > halfSizeWindow )
{
m_realWidth = 0.5f * ParentWindow.position.width;
if ( m_resizeDelta > 0 )
{
m_resizeDelta = m_realWidth - m_maximizedArea.width;
}
else
{
m_resizeDelta = m_maximizedArea.width - m_realWidth;
}
}
}
}
GUI.enabled = guiEnabledBuffer;
GUI.color = colorBuffer;
}
public void OnLostFocus()
{
if ( m_isResizing )
{
m_isResizing = false;
}
}
virtual public void Destroy()
{
m_empty = null;
m_resizeAreaStyle = null;
}
public float InitialX
{
get { return m_maximizedArea.x; }
set { m_maximizedArea.x = value; }
}
public float Width
{
get { return m_maximizedArea.width; }
set { m_maximizedArea.width = value; }
}
public float RealWidth
{
get { return m_realWidth; }
}
public float Height
{
get { return m_maximizedArea.height; }
set { m_maximizedArea.height = value; }
}
public Rect Size
{
get { return m_maximizedArea; }
}
public virtual bool IsInside( Vector2 position )
{
if ( !m_isActive )
return false;
return m_transformedArea.Contains( position );
}
public bool IsMaximized
{
get { return m_isMaximized; }
set { m_isMaximized = value; }
}
public Rect TransformedArea
{
get { return m_transformedArea; }
}
public bool Resizable { set { m_resizable = value; } }
public bool IsResizing { get { return m_isResizing; } }
public bool LockOnMinimize
{
set
{
if ( m_lockOnMinimize == value )
return;
m_lockOnMinimize = value;
if ( value )
{
m_preLockState = m_isMaximized;
m_isMaximized = false;
}
else
{
m_isMaximized = m_preLockState;
}
}
}
public bool IsActive
{
get { return m_isActive; }
}
public AmplifyShaderEditorWindow ParentWindow { get { return m_parentWindow; } set { m_parentWindow = value; } }
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5d535d3799a3ef547aea607fdc8b947b
timeCreated: 1481126956
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,557 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using UnityEditorInternal;
namespace AmplifyShaderEditor
{
public sealed class NodeParametersWindow : MenuParent
{
private int m_lastSelectedNode = -1;
private const string TitleStr = "Node Properties";
private GUIStyle m_nodePropertiesStyle;
private GUIContent m_dummyContent = new GUIContent();
private GUIStyle m_propertyAdjustment;
private ReorderableList m_functionInputsReordableList = null;
private int m_functionInputsLastCount = 0;
private ReorderableList m_functionSwitchesReordableList = null;
private int m_functionSwitchesLastCount = 0;
private ReorderableList m_functionOutputsReordableList = null;
private int m_functionOutputsLastCount = 0;
private ReorderableList m_propertyReordableList = null;
private int m_lastCount = 0;
private bool m_forceUpdate = false;
[SerializeField]
private List<PropertyNode> m_propertyReordableNodes = new List<PropertyNode>();
// width and height are between [0,1] and represent a percentage of the total screen area
public NodeParametersWindow( AmplifyShaderEditorWindow parentWindow ) : base( parentWindow, 0, 0, 285, 0, string.Empty, MenuAnchor.TOP_LEFT, MenuAutoSize.MATCH_VERTICAL )
{
SetMinimizedArea( -225, 0, 260, 0 );
}
public void OnShaderFunctionLoad()
{
m_functionInputsReordableList = null;
m_functionSwitchesReordableList = null;
m_functionOutputsReordableList = null;
}
public bool Draw( Rect parentPosition, ParentNode selectedNode, Vector2 mousePosition, int mouseButtonId, bool hasKeyboardFocus )
{
bool changeCheck = false;
base.Draw( parentPosition, mousePosition, mouseButtonId, hasKeyboardFocus );
if ( m_nodePropertiesStyle == null )
{
m_nodePropertiesStyle = UIUtils.GetCustomStyle( CustomStyle.NodePropertiesTitle );
m_nodePropertiesStyle.normal.textColor = m_nodePropertiesStyle.active.textColor = EditorGUIUtility.isProSkin ? new Color( 1f, 1f, 1f ) : new Color( 0f, 0f, 0f );
}
if ( m_isMaximized )
{
KeyCode key = Event.current.keyCode;
if ( m_isMouseInside || hasKeyboardFocus )
{
if ( key == ShortcutsManager.ScrollUpKey )
{
m_currentScrollPos.y -= 10;
if ( m_currentScrollPos.y < 0 )
{
m_currentScrollPos.y = 0;
}
Event.current.Use();
}
if ( key == ShortcutsManager.ScrollDownKey )
{
m_currentScrollPos.y += 10;
Event.current.Use();
}
}
if( m_forceUpdate )
{
if( m_propertyReordableList != null )
m_propertyReordableList.ReleaseKeyboardFocus();
m_propertyReordableList = null;
if ( m_functionInputsReordableList != null )
m_functionInputsReordableList.ReleaseKeyboardFocus();
m_functionInputsReordableList = null;
if( m_functionSwitchesReordableList != null )
m_functionSwitchesReordableList.ReleaseKeyboardFocus();
m_functionSwitchesReordableList = null;
if ( m_functionOutputsReordableList != null )
m_functionOutputsReordableList.ReleaseKeyboardFocus();
m_functionOutputsReordableList = null;
m_forceUpdate = false;
}
GUILayout.BeginArea( m_transformedArea, m_content, m_style );
{
//Draw selected node parameters
if ( selectedNode != null )
{
// this hack is need because without it the several FloatFields/Textfields/... would show wrong values ( different from the ones they were assigned to show )
if ( m_lastSelectedNode != selectedNode.UniqueId )
{
m_lastSelectedNode = selectedNode.UniqueId;
GUI.FocusControl( "" );
}
EditorGUILayout.BeginVertical();
{
EditorGUILayout.Separator();
if ( selectedNode.UniqueId == ParentWindow.CurrentGraph.CurrentMasterNodeId )
{
m_dummyContent.text = "Output Node";
}
else
{
if ( selectedNode.Attributes != null )
{
m_dummyContent.text = selectedNode.Attributes.Name;
}
else if ( selectedNode is CommentaryNode )
{
m_dummyContent.text = "Commentary";
}
else
{
m_dummyContent.text = TitleStr;
}
}
EditorGUILayout.LabelField( m_dummyContent, m_nodePropertiesStyle );
EditorGUILayout.Separator();
//UIUtils.RecordObject( selectedNode , "Changing properties on node " + selectedNode.UniqueId);
m_currentScrollPos = EditorGUILayout.BeginScrollView( m_currentScrollPos, GUILayout.Width( 0 ), GUILayout.Height( 0 ) );
float labelWidth = EditorGUIUtility.labelWidth;
//if( selectedNode.TextLabelWidth > 0 )
// EditorGUIUtility.labelWidth = selectedNode.TextLabelWidth;
//else
EditorGUIUtility.labelWidth = TransformedArea.width * 0.42f;
changeCheck = selectedNode.SafeDrawProperties();
EditorGUIUtility.labelWidth = labelWidth;
EditorGUILayout.EndScrollView();
}
EditorGUILayout.EndVertical();
if ( changeCheck )
{
if ( selectedNode.ConnStatus == NodeConnectionStatus.Connected )
ParentWindow.SetSaveIsDirty();
}
}
else
{
//Draw Graph Params
EditorGUILayout.BeginVertical();
{
EditorGUILayout.Separator();
EditorGUILayout.LabelField( "Graph Properties", m_nodePropertiesStyle );
EditorGUILayout.Separator();
m_currentScrollPos = EditorGUILayout.BeginScrollView( m_currentScrollPos, GUILayout.Width( 0 ), GUILayout.Height( 0 ) );
float labelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 90;
bool generalIsVisible = m_parentWindow.InnerWindowVariables.ExpandedGeneralShaderOptions;
NodeUtils.DrawPropertyGroup( ref generalIsVisible, " General", DrawGeneralFunction );
m_parentWindow.InnerWindowVariables.ExpandedGeneralShaderOptions = generalIsVisible;
AmplifyShaderFunction function = ParentWindow.CurrentGraph.CurrentShaderFunction;
if( function != null )
{
//function.AdditionalIncludes.Draw( ParentWindow.CurrentGraph.CurrentOutputNode );
//function.AdditionalPragmas.Draw( ParentWindow.CurrentGraph.CurrentOutputNode );
function.AdditionalDirectives.Draw( ParentWindow.CurrentGraph.CurrentOutputNode );
}
bool inputIsVisible = m_parentWindow.InnerWindowVariables.ExpandedFunctionInputs;
NodeUtils.DrawPropertyGroup( ref inputIsVisible, " Function Inputs", DrawFunctionInputs );
m_parentWindow.InnerWindowVariables.ExpandedFunctionInputs = inputIsVisible;
bool swicthIsVisible = m_parentWindow.InnerWindowVariables.ExpandedFunctionSwitches;
NodeUtils.DrawPropertyGroup( ref swicthIsVisible, " Function Switches", DrawFunctionSwitches );
m_parentWindow.InnerWindowVariables.ExpandedFunctionSwitches = swicthIsVisible;
bool outputIsVisible = m_parentWindow.InnerWindowVariables.ExpandedFunctionOutputs;
NodeUtils.DrawPropertyGroup( ref outputIsVisible, " Function Outputs", DrawFunctionOutputs );
m_parentWindow.InnerWindowVariables.ExpandedFunctionOutputs = outputIsVisible;
bool properties = ParentWindow.InnerWindowVariables.ExpandedProperties;
NodeUtils.DrawPropertyGroup( ref properties, " Material Properties", DrawFunctionProperties );
ParentWindow.InnerWindowVariables.ExpandedProperties = properties;
EditorGUIUtility.labelWidth = labelWidth;
EditorGUILayout.EndScrollView();
}
EditorGUILayout.EndVertical();
}
}
// Close window area
GUILayout.EndArea();
}
PostDraw();
return changeCheck;
}
public void DrawGeneralFunction()
{
AmplifyShaderFunction function = ParentWindow.CurrentGraph.CurrentShaderFunction;
if ( function == null )
return;
float cacheWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 115;
SerializedObject serializedObject = new UnityEditor.SerializedObject( function );
if ( serializedObject != null )
{
SerializedProperty temo = serializedObject.FindProperty( "m_description" );
EditorGUILayout.PropertyField( temo, new GUIContent( " Description" ) );
SerializedProperty cat = serializedObject.FindProperty( "m_nodeCategory" );
SerializedProperty ppos = serializedObject.FindProperty( "m_previewPosition" );
EditorGUILayout.PropertyField( ppos, new GUIContent( "Preview Position" ) );
cat.intValue = ParentWindow.CurrentGraph.CurrentOutputNode.EditorGUILayoutPopup( "Category", cat.intValue, UIUtils.CategoryPresets );
if( cat.enumValueIndex == 0 )
{
SerializedProperty custCat = serializedObject.FindProperty( "m_customNodeCategory" );
EditorGUILayout.PropertyField( custCat, new GUIContent( "Custom" ) );
}
SerializedProperty hidden = serializedObject.FindProperty( "m_hidden" );
EditorGUILayout.PropertyField( hidden, new GUIContent( "Hidden" ) );
serializedObject.ApplyModifiedProperties();
}
EditorGUIUtility.labelWidth = cacheWidth;
}
public void DrawFunctionInputs()
{
List<FunctionInput> functionInputNodes = UIUtils.FunctionInputList();
if ( m_functionInputsReordableList == null || functionInputNodes.Count != m_functionInputsLastCount )
{
functionInputNodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } );
m_functionInputsReordableList = new ReorderableList( functionInputNodes, typeof( FunctionInput ), true, false, false, false );
m_functionInputsReordableList.headerHeight = 0;
m_functionInputsReordableList.footerHeight = 0;
m_functionInputsReordableList.showDefaultBackground = false;
m_functionInputsReordableList.drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) =>
{
EditorGUI.LabelField( rect, functionInputNodes[ index ].InputName );
};
m_functionInputsReordableList.onChangedCallback = ( list ) =>
{
//for ( int i = 0; i < functionInputNodes.Count; i++ )
//{
// functionInputNodes[ i ].OrderIndex = i;
//}
ForceInputReorder( ref functionInputNodes );
};
m_functionInputsLastCount = m_functionInputsReordableList.count;
}
if ( m_functionInputsReordableList != null )
{
if ( m_propertyAdjustment == null )
{
m_propertyAdjustment = new GUIStyle();
m_propertyAdjustment.padding.left = 17;
}
EditorGUILayout.BeginVertical( m_propertyAdjustment );
m_functionInputsReordableList.DoLayoutList();
EditorGUILayout.EndVertical();
}
}
public void ForceInputReorder( ref List<FunctionInput> functionInputNodes )
{
for( int i = 0; i < functionInputNodes.Count; i++ )
{
functionInputNodes[ i ].OrderIndex = i;
}
}
public void DrawFunctionSwitches()
{
List<FunctionSwitch> functionSwitchNodes = UIUtils.FunctionSwitchList();
if( m_functionSwitchesReordableList == null || functionSwitchNodes.Count != m_functionSwitchesLastCount )
{
functionSwitchNodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } );
UIUtils.UpdateFunctionSwitchArr();
m_functionSwitchesReordableList = new ReorderableList( functionSwitchNodes, typeof( FunctionSwitch ), true, false, false, false );
m_functionSwitchesReordableList.headerHeight = 0;
m_functionSwitchesReordableList.footerHeight = 0;
m_functionSwitchesReordableList.showDefaultBackground = false;
m_functionSwitchesReordableList.drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) =>
{
EditorGUI.LabelField( rect, functionSwitchNodes[ index ].OptionLabel );
};
m_functionSwitchesReordableList.onChangedCallback = ( list ) =>
{
ForceSwitchesReorder(ref functionSwitchNodes );
};
m_functionSwitchesLastCount = m_functionSwitchesReordableList.count;
}
if( m_functionSwitchesReordableList != null )
{
if( m_propertyAdjustment == null )
{
m_propertyAdjustment = new GUIStyle();
m_propertyAdjustment.padding.left = 17;
}
EditorGUILayout.BeginVertical( m_propertyAdjustment );
m_functionSwitchesReordableList.DoLayoutList();
EditorGUILayout.EndVertical();
}
}
public void ForceSwitchesReorder( ref List<FunctionSwitch> functionSwitchNodes )
{
for( int i = 0; i < functionSwitchNodes.Count; i++ )
{
functionSwitchNodes[ i ].OrderIndex = i;
}
UIUtils.UpdateFunctionSwitchArr();
}
public void DrawFunctionOutputs()
{
List<FunctionOutput> functionOutputNodes = UIUtils.FunctionOutputList();
if ( m_functionOutputsReordableList == null || functionOutputNodes.Count != m_functionOutputsLastCount )
{
functionOutputNodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } );
m_functionOutputsReordableList = new ReorderableList( functionOutputNodes, typeof( FunctionOutput ), true, false, false, false );
m_functionOutputsReordableList.headerHeight = 0;
m_functionOutputsReordableList.footerHeight = 0;
m_functionOutputsReordableList.showDefaultBackground = false;
m_functionOutputsReordableList.drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) =>
{
EditorGUI.LabelField( rect, functionOutputNodes[ index ].OutputName );
};
m_functionOutputsReordableList.onChangedCallback = ( list ) =>
{
for ( int i = 0; i < functionOutputNodes.Count; i++ )
{
functionOutputNodes[ i ].OrderIndex = i;
}
};
m_functionOutputsLastCount = m_functionOutputsReordableList.count;
}
if ( m_functionOutputsReordableList != null )
{
if ( m_propertyAdjustment == null )
{
m_propertyAdjustment = new GUIStyle();
m_propertyAdjustment.padding.left = 17;
}
EditorGUILayout.BeginVertical( m_propertyAdjustment );
m_functionOutputsReordableList.DoLayoutList();
EditorGUILayout.EndVertical();
}
}
private void RefreshVisibleList( ref List<PropertyNode> allNodes )
{
// temp reference for lambda expression
List<PropertyNode> nodes = allNodes;
m_propertyReordableNodes.Clear();
for( int i = 0; i < nodes.Count; i++ )
{
ReordenatorNode rnode = nodes[ i ] as ReordenatorNode;
if( ( rnode == null || !rnode.IsInside ) && ( !m_propertyReordableNodes.Exists( x => x.PropertyName.Equals( nodes[ i ].PropertyName ) ) ) )
m_propertyReordableNodes.Add( nodes[ i ] );
}
m_propertyReordableNodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } );
}
public void DrawFunctionProperties()
{
List<PropertyNode> nodes = UIUtils.PropertyNodesList();
if( nodes.Count != m_lastCount )
{
RefreshVisibleList( ref nodes );
m_lastCount = nodes.Count;
}
if( m_propertyReordableList == null )
{
m_propertyReordableList = new ReorderableList( m_propertyReordableNodes, typeof( PropertyNode ), true, false, false, false )
{
headerHeight = 0,
footerHeight = 0,
showDefaultBackground = false,
drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) =>
{
var first = rect;
first.width *= 0.60f;
EditorGUI.LabelField( first, m_propertyReordableNodes[ index ].PropertyInspectorName );
var second = rect;
second.width *= 0.4f;
second.x += first.width;
if( GUI.Button( second, m_propertyReordableNodes[ index ].PropertyName, new GUIStyle( "AssetLabel Partial" ) ) )
{
UIUtils.FocusOnNode( m_propertyReordableNodes[ index ], 1, false );
}
},
onReorderCallback = ( list ) =>
{
ReorderList( ref nodes );
}
};
ReorderList( ref nodes );
}
if( m_propertyReordableList != null )
{
if( m_propertyAdjustment == null )
{
m_propertyAdjustment = new GUIStyle();
m_propertyAdjustment.padding.left = 17;
}
EditorGUILayout.BeginVertical( m_propertyAdjustment );
m_propertyReordableList.DoLayoutList();
EditorGUILayout.EndVertical();
}
}
public void ForceReordering()
{
List<PropertyNode> nodes = UIUtils.PropertyNodesList();
ReorderList( ref nodes );
List<FunctionInput> functionInputNodes = UIUtils.FunctionInputList();
ForceInputReorder( ref functionInputNodes );
List<FunctionSwitch> functionSwitchNodes = UIUtils.FunctionSwitchList();
ForceSwitchesReorder( ref functionSwitchNodes );
//RecursiveLog();
}
private void RecursiveLog()
{
List<PropertyNode> nodes = UIUtils.PropertyNodesList();
nodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } );
for( int i = 0; i < nodes.Count; i++ )
{
if( ( nodes[ i ] is ReordenatorNode ) )
( nodes[ i ] as ReordenatorNode ).RecursiveLog();
else
Debug.Log( nodes[ i ].OrderIndex + " " + nodes[ i ].PropertyName );
}
}
private void ReorderList( ref List<PropertyNode> nodes )
{
// clear lock list before reordering because of multiple sf being used
for( int i = 0; i < nodes.Count; i++ )
{
ReordenatorNode rnode = nodes[ i ] as ReordenatorNode;
if ( rnode != null )
rnode.RecursiveClear();
}
int propoffset = 0;
int count = 0;
for ( int i = 0; i < m_propertyReordableNodes.Count; i++ )
{
ReordenatorNode renode = m_propertyReordableNodes[ i ] as ReordenatorNode;
if ( renode != null )
{
if ( !renode.IsInside )
{
m_propertyReordableNodes[ i ].OrderIndex = count + propoffset;
if ( renode.PropertyListCount > 0 )
{
propoffset += renode.RecursiveCount();
// the same reordenator can exist multiple times, apply ordering to all of them
for( int j = 0; j < nodes.Count; j++ )
{
ReordenatorNode pnode = ( nodes[ j ] as ReordenatorNode );
if ( pnode != null && pnode.PropertyName.Equals( renode.PropertyName ) )
{
pnode.OrderIndex = renode.RawOrderIndex;
pnode.RecursiveSetOrderOffset( renode.RawOrderIndex, true );
}
}
}
else
{
count++;
}
}
else
{
m_propertyReordableNodes[ i ].OrderIndex = 0;
}
}
else
{
m_propertyReordableNodes[ i ].OrderIndex = count + propoffset;
count++;
}
}
}
public override void Destroy()
{
base.Destroy();
m_functionInputsReordableList = null;
m_functionOutputsReordableList = null;
m_propertyReordableList = null;
}
public bool ForceUpdate
{
get { return m_forceUpdate; }
set { m_forceUpdate = value; }
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d09f21096aa7c9f438e91a6e7f2621fb
timeCreated: 1481126959
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,56 @@
using UnityEngine;
namespace AmplifyShaderEditor
{
public class NodeWireReferencesUtils
{
public WireReference InputPortReference = new WireReference();
public WireReference SwitchPortReference = new WireReference();
public WireReference OutputPortReference = new WireReference();
public Vector2 SnapPosition = Vector2.zero;
public bool SnapEnabled = false;
public WireReference SnapPort = new WireReference();
public bool ValidReferences()
{
return ( InputPortReference.IsValid || OutputPortReference.IsValid );
}
public void InvalidateReferences()
{
InputPortReference.Invalidate();
OutputPortReference.Invalidate();
SnapPort.Invalidate();
SnapEnabled = false;
}
public void SetOutputReference( int nodeId, int portId, WirePortDataType dataType, bool typeLocked )
{
if( InputPortReference.IsValid )
InputPortReference.Invalidate();
OutputPortReference.SetReference( nodeId, portId, dataType, typeLocked );
}
public void SetInputReference( int nodeId, int portId, WirePortDataType dataType, bool typeLocked )
{
if( OutputPortReference.IsValid )
OutputPortReference.Invalidate();
InputPortReference.SetReference( nodeId, portId, dataType, typeLocked );
}
public void ActivateSnap( Vector2 position, WirePort port )
{
SnapPort.SetReference( port );
SnapEnabled = true;
SnapPosition = position;
}
public void DeactivateSnap()
{
SnapEnabled = false;
SnapPort.Invalidate();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bfbc736093c900c418a7668e3003663a
timeCreated: 1500289690
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a89b03eb735b82a4da19a8381846935f
folderAsset: yes
timeCreated: 1481126946
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,101 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections.Generic;
using System;
namespace AmplifyShaderEditor
{
public sealed class ContextPalette : PaletteParent
{
private Vector3 m_position;
private Vector2 m_startDropPosition;
public ContextPalette( AmplifyShaderEditorWindow parentWindow ) : base( parentWindow, 0, 0, 250, 250, string.Empty, MenuAnchor.NONE, MenuAutoSize.NONE )
{
m_isActive = false;
OnPaletteNodeCreateEvt += OnOptionSelected;
m_searchFilterControl += "CONTEXTPALETTE";
}
public override void OnEnterPressed(int index = 0)
{
if ( m_searchFilter.Length > 0 && m_currentItems.Count > 0 )
{
FireNodeCreateEvent( m_currentItems[ index ].NodeType, m_currentItems[ index ].Name, m_currentItems[ index ].Function );
}
else
{
Disable();
}
}
public override void OnEscapePressed()
{
Disable();
if ( m_parentWindow.WireReferenceUtils.ValidReferences() )
{
m_parentWindow.WireReferenceUtils.InvalidateReferences();
}
}
public override void Draw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus )
{
//if ( !_isActive )
// return;
if ( Event.current.type == EventType.MouseDown && !IsInside( Event.current.mousePosition ) )
{
Disable();
return;
}
base.Draw( parentPosition, mousePosition, mouseButtonId, hasKeyboadFocus );
}
public void Show( Vector2 position, Rect cameraInfo )
{
m_startDropPosition = position;
m_maximizedArea.x = ( position.x + m_maximizedArea.width ) > cameraInfo.width ? ( cameraInfo.width - 1.1f * m_maximizedArea.width ) : position.x;
m_maximizedArea.y = ( position.y + m_maximizedArea.height ) > cameraInfo.height ? ( cameraInfo.height - 1.1f * m_maximizedArea.height ) : position.y;
m_position = new Vector3( m_maximizedArea.x, m_maximizedArea.y, 0f );
m_isActive = true;
m_focusOnSearch = true;
}
// This override is removing focus from our window ... need to figure out a workaround before re-using it
//public override bool CheckButton( GUIContent content, GUIStyle style, int buttonId )
//{
// if ( buttonId != m_validButtonId )
// return false;
// return GUILayout.Button( content, style );
//}
void OnOptionSelected( System.Type type, string name, AmplifyShaderFunction function )
{
Disable();
}
public void Disable()
{
m_isActive = false;
}
public Vector2 StartDropPosition
{
get { return m_startDropPosition; }
}
public Vector3 CurrentPosition
{
get { return m_position; }
}
public Vector2 CurrentPosition2D
{
get { return new Vector2( m_position.x, m_position.y ); }
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 15597b146a1fc154abd63ac75cffb73f
timeCreated: 1481126953
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,573 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using System;
using System.Text.RegularExpressions;
namespace AmplifyShaderEditor
{
public class PaletteFilterData
{
public bool Visible;
public bool HasCommunityData;
public List<ContextMenuItem> Contents;
public PaletteFilterData( bool visible )
{
Visible = visible;
Contents = new List<ContextMenuItem>();
}
}
public class PaletteParent : MenuParent
{
private const float ItemSize = 18;
public delegate void OnPaletteNodeCreate( System.Type type, string name, AmplifyShaderFunction function );
public event OnPaletteNodeCreate OnPaletteNodeCreateEvt;
private string m_searchFilterStr = "Search";
protected string m_searchFilterControl = "SHADERNAMETEXTFIELDCONTROLNAME";
protected bool m_focusOnSearch = false;
protected bool m_defaultCategoryVisible = false;
//protected List<ContextMenuItem> m_allItems;
protected List<ContextMenuItem> m_currentItems;
protected Dictionary<string, PaletteFilterData> m_currentCategories;
private bool m_forceUpdate = true;
protected string m_searchFilter = string.Empty;
private float m_searchLabelSize = -1;
private GUIStyle m_buttonStyle;
private GUIStyle m_foldoutStyle;
protected bool m_previousWindowIsFunction = false;
protected int m_validButtonId = 0;
protected int m_initialSeparatorAmount = 1;
private Vector2 m_currScrollBarDims = new Vector2( 1, 1 );
public PaletteParent( AmplifyShaderEditorWindow parentWindow, float x, float y, float width, float height, string name, MenuAnchor anchor = MenuAnchor.NONE, MenuAutoSize autoSize = MenuAutoSize.NONE ) : base( parentWindow, x, y, width, height, name, anchor, autoSize )
{
m_searchFilter = string.Empty;
m_currentCategories = new Dictionary<string, PaletteFilterData>();
//m_allItems = items;
m_currentItems = new List<ContextMenuItem>();
}
public virtual void OnEnterPressed( int index = 0 ) { }
public virtual void OnEscapePressed() { }
public void FireNodeCreateEvent( System.Type type, string name, AmplifyShaderFunction function )
{
OnPaletteNodeCreateEvt( type, name, function );
}
public override void Draw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus )
{
base.Draw( parentPosition, mousePosition, mouseButtonId, hasKeyboadFocus );
if( m_previousWindowIsFunction != ParentWindow.IsShaderFunctionWindow )
{
m_forceUpdate = true;
}
m_previousWindowIsFunction = ParentWindow.IsShaderFunctionWindow;
List<ContextMenuItem> allItems = ParentWindow.ContextMenuInstance.MenuItems;
if( m_searchLabelSize < 0 )
{
m_searchLabelSize = GUI.skin.label.CalcSize( new GUIContent( m_searchFilterStr ) ).x;
}
if( m_foldoutStyle == null )
{
m_foldoutStyle = new GUIStyle( GUI.skin.GetStyle( "foldout" ) );
m_foldoutStyle.fontStyle = FontStyle.Bold;
}
if( m_buttonStyle == null )
{
m_buttonStyle = UIUtils.Label;
}
Event currenEvent = Event.current;
GUILayout.BeginArea( m_transformedArea, m_content, m_style );
{
for( int i = 0; i < m_initialSeparatorAmount; i++ )
{
EditorGUILayout.Separator();
}
if( currenEvent.type == EventType.KeyDown )
{
KeyCode key = currenEvent.keyCode;
//if ( key == KeyCode.Return || key == KeyCode.KeypadEnter )
// OnEnterPressed();
if( ( currenEvent.keyCode == KeyCode.KeypadEnter || currenEvent.keyCode == KeyCode.Return ) && currenEvent.type == EventType.KeyDown )
{
int index = m_currentItems.FindIndex( x => GUI.GetNameOfFocusedControl().Equals( x.ItemUIContent.text + m_resizable ) );
if( index > -1 )
OnEnterPressed( index );
else
OnEnterPressed();
}
if( key == KeyCode.Escape )
OnEscapePressed();
if( m_isMouseInside || hasKeyboadFocus )
{
if( key == ShortcutsManager.ScrollUpKey )
{
m_currentScrollPos.y -= 10;
if( m_currentScrollPos.y < 0 )
{
m_currentScrollPos.y = 0;
}
currenEvent.Use();
}
if( key == ShortcutsManager.ScrollDownKey )
{
m_currentScrollPos.y += 10;
currenEvent.Use();
}
}
}
float width = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = m_searchLabelSize;
EditorGUI.BeginChangeCheck();
{
GUI.SetNextControlName( m_searchFilterControl + m_resizable );
m_searchFilter = EditorGUILayout.TextField( m_searchFilterStr, m_searchFilter );
if( m_focusOnSearch )
{
m_focusOnSearch = false;
EditorGUI.FocusTextInControl( m_searchFilterControl + m_resizable );
}
}
if( EditorGUI.EndChangeCheck() )
m_forceUpdate = true;
EditorGUIUtility.labelWidth = width;
bool usingSearchFilter = ( m_searchFilter.Length == 0 );
m_currScrollBarDims.x = m_transformedArea.width;
m_currScrollBarDims.y = m_transformedArea.height - 2 - 16 - 2 - 7 * m_initialSeparatorAmount - 2;
m_currentScrollPos = EditorGUILayout.BeginScrollView( m_currentScrollPos/*, GUILayout.Width( 242 ), GUILayout.Height( 250 - 2 - 16 - 2 - 7 - 2) */);
{
if( m_forceUpdate )
{
m_forceUpdate = false;
//m_currentItems.Clear();
m_currentCategories.Clear();
if( usingSearchFilter )
{
for( int i = 0; i < allItems.Count; i++ )
{
//m_currentItems.Add( allItems[ i ] );
if( !m_currentCategories.ContainsKey( allItems[ i ].Category ) )
{
m_currentCategories.Add( allItems[ i ].Category, new PaletteFilterData( m_defaultCategoryVisible ) );
//m_currentCategories[ allItems[ i ].Category ].HasCommunityData = allItems[ i ].NodeAttributes.FromCommunity || m_currentCategories[ allItems[ i ].Category ].HasCommunityData;
}
m_currentCategories[ allItems[ i ].Category ].Contents.Add( allItems[ i ] );
}
}
else
{
for( int i = 0; i < allItems.Count; i++ )
{
var searchList = m_searchFilter.Trim( ' ' ).ToLower().Split(' ');
int matchesFound = 0;
for( int k = 0; k < searchList.Length; k++ )
{
MatchCollection wordmatch = Regex.Matches( allItems[ i ].Tags, "\\b"+searchList[ k ] );
if( wordmatch.Count > 0 )
matchesFound++;
else
break;
}
if( searchList.Length == matchesFound )
{
//m_currentItems.Add( allItems[ i ] );
if( !m_currentCategories.ContainsKey( allItems[ i ].Category ) )
{
m_currentCategories.Add( allItems[ i ].Category, new PaletteFilterData( m_defaultCategoryVisible ) );
//m_currentCategories[ allItems[ i ].Category ].HasCommunityData = allItems[ i ].NodeAttributes.FromCommunity || m_currentCategories[ allItems[ i ].Category ].HasCommunityData;
}
m_currentCategories[ allItems[ i ].Category ].Contents.Add( allItems[ i ] );
}
}
}
var categoryEnumerator = m_currentCategories.GetEnumerator();
while( categoryEnumerator.MoveNext() )
{
categoryEnumerator.Current.Value.Contents.Sort( ( x, y ) => x.CompareTo( y, usingSearchFilter ) );
}
//sort current list respecting categories
m_currentItems.Clear();
foreach( var item in m_currentCategories )
{
for( int i = 0; i < item.Value.Contents.Count; i++ )
{
m_currentItems.Add( item.Value.Contents[ i ] );
}
}
}
string watching = string.Empty;
// unselect the main search field so it can focus list elements next
if( ( currenEvent.keyCode == KeyCode.DownArrow || currenEvent.keyCode == KeyCode.UpArrow ) && m_searchFilter.Length > 0 )
{
if( GUI.GetNameOfFocusedControl().Equals( m_searchFilterControl + m_resizable ) )
{
EditorGUI.FocusTextInControl( null );
}
}
if( currenEvent.keyCode == KeyCode.DownArrow && currenEvent.type == EventType.KeyDown )
{
currenEvent.Use();
int nextIndex = m_currentItems.FindIndex( x => GUI.GetNameOfFocusedControl().Equals( x.ItemUIContent.text + m_resizable ) ) + 1;
if( nextIndex == m_currentItems.Count )
nextIndex = 0;
watching = m_currentItems[ nextIndex ].ItemUIContent.text + m_resizable;
GUI.FocusControl( watching );
}
if( currenEvent.keyCode == KeyCode.UpArrow && currenEvent.type == EventType.KeyDown )
{
currenEvent.Use();
int nextIndex = m_currentItems.FindIndex( x => GUI.GetNameOfFocusedControl().Equals( x.ItemUIContent.text + m_resizable ) ) - 1;
if( nextIndex < 0 )
nextIndex = m_currentItems.Count - 1;
watching = m_currentItems[ nextIndex ].ItemUIContent.text + m_resizable;
GUI.FocusControl( watching );
}
if( currenEvent.keyCode == KeyCode.Tab )
{
ContextMenuItem item = m_currentItems.Find( x => GUI.GetNameOfFocusedControl().Equals( x.ItemUIContent.text + m_resizable ) );
if( item != null )
{
watching = item.ItemUIContent.text + m_resizable;
}
}
float currPos = 0;
var enumerator = m_currentCategories.GetEnumerator();
float cache = EditorGUIUtility.labelWidth;
while( enumerator.MoveNext() )
{
var current = enumerator.Current;
bool visible = GUILayout.Toggle( current.Value.Visible, current.Key, m_foldoutStyle );
if( m_validButtonId == mouseButtonId )
{
current.Value.Visible = visible;
}
currPos += ItemSize;
if( m_searchFilter.Length > 0 || current.Value.Visible )
{
for( int i = 0; i < current.Value.Contents.Count; i++ )
{
//if ( !IsItemVisible( currPos ) )
//{
// // Invisible
// GUILayout.Space( ItemSize );
//}
//else
{
currPos += ItemSize;
// Visible
EditorGUILayout.BeginHorizontal();
GUILayout.Space( 16 );
//if ( m_isMouseInside )
//{
// //GUI.SetNextControlName( current.Value.Contents[ i ].ItemUIContent.text );
// if ( CheckButton( current.Value.Contents[ i ].ItemUIContent, m_buttonStyle, mouseButtonId ) )
// {
// int controlID = GUIUtility.GetControlID( FocusType.Passive );
// GUIUtility.hotControl = controlID;
// OnPaletteNodeCreateEvt( current.Value.Contents[ i ].NodeType, current.Value.Contents[ i ].Name, current.Value.Contents[ i ].Function );
// }
//}
//else
{
Rect thisRect = EditorGUILayout.GetControlRect( false, 16f, EditorStyles.label );
//if ( m_resizable )
{
if( GUI.RepeatButton( thisRect, string.Empty, EditorStyles.label ) )
{
int controlID = GUIUtility.GetControlID( FocusType.Passive );
GUIUtility.hotControl = controlID;
OnPaletteNodeCreateEvt( current.Value.Contents[ i ].NodeType, current.Value.Contents[ i ].Name, current.Value.Contents[ i ].Function );
//unfocus to make it focus the next text field correctly
GUI.FocusControl( null );
}
}
GUI.SetNextControlName( current.Value.Contents[ i ].ItemUIContent.text + m_resizable );
//EditorGUI.SelectableLabel( thisRect, current.Value.Contents[ i ].ItemUIContent.text, EditorStyles.label );
//float cache = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = thisRect.width;
EditorGUI.Toggle( thisRect, current.Value.Contents[ i ].ItemUIContent.text, false, EditorStyles.label );
EditorGUIUtility.labelWidth = cache;
if( watching == current.Value.Contents[ i ].ItemUIContent.text + m_resizable )
{
bool boundBottom = currPos - m_currentScrollPos.y > m_currScrollBarDims.y;
bool boundTop = currPos - m_currentScrollPos.y - 4 <= 0;
if( boundBottom )
m_currentScrollPos.y = currPos - m_currScrollBarDims.y + 2;
else if( boundTop )
m_currentScrollPos.y = currPos - 18;
//else if ( boundBottom && !downDirection )
// m_currentScrollPos.y = currPos - m_currScrollBarDims.y + 2;
//else if ( boundTop && downDirection )
// m_currentScrollPos.y = currPos - 18;
}
}
EditorGUILayout.EndHorizontal();
}
//currPos += ItemSize;
}
}
}
EditorGUIUtility.labelWidth = cache;
}
EditorGUILayout.EndScrollView();
}
GUILayout.EndArea();
}
public void CheckCommunityNodes()
{
var enumerator = m_currentCategories.GetEnumerator();
while( enumerator.MoveNext() )
{
var current = enumerator.Current;
current.Value.HasCommunityData = false;
int count = current.Value.Contents.Count;
for( int i = 0; i < count; i++ )
{
if( current.Value.Contents[ i ].NodeAttributes.FromCommunity )
{
current.Value.HasCommunityData = true;
break;
}
}
}
}
public void DumpAvailableNodes( bool fromCommunity, string pathname )
{
string noTOCHeader = "__NOTOC__\n";
string nodesHeader = "== Available Node Categories ==\n";
string InitialCategoriesFormat = "[[#{0}|{0}]]<br>\n";
string InitialCategories = string.Empty;
string CurrentCategoryFormat = "\n== {0} ==\n\n";
//string NodesFootFormat = "[[Unity Products:Amplify Shader Editor/{0} | Learn More]] -\n[[#Top|Back to Categories]]\n";
string NodesFootFormatSep = "[[#Top|Back to Top]]\n----\n";
string OverallFoot = "[[Category:Nodes]]";
string NodeInfoBeginFormat = "<div class=\"nodecard\">\n";
string nodeInfoBodyFormat = "{{| id=\"{2}\" class=\"wikitable\" |\n" +
"|- \n" +
"| <div>[[Unity Products:Amplify Shader Editor/{1}|<img class=\"responsive-img\" src=\"http://amplify.pt/Nodes/{0}.jpg\">]]</div>\n" +
"<div>\n" +
"{{| style=\"width: 100%; height: 150px;\"\n" +
"|-\n" +
"| [[Unity Products:Amplify Shader Editor/{1}|'''{2}''']]\n" +
"|- style=\"vertical-align:top; height: 100%;\" |\n" +
"|<p class=\"cardtext\">{3}</p>\n" +
"|- style=\"text-align:right;\" |\n" +
"|{4}[[Unity Products:Amplify Shader Editor/{1} | Learn More]]\n" +
"|}}</div>\n" +
"|}}\n";
string NodeInfoEndFormat = "</div>\n";
//string NodeInfoBeginFormat = "<span style=\"color:#c00;display:block;\">This page is under construction!</span>\n\n";
//string nodeInfoBodyFormat = "<img style=\"float:left; margin-right:10px;\" src=\"http://amplify.pt/Nodes/{0}.jpg\">\n[[Unity Products:Amplify Shader Editor/{1}|'''{2}''']]\n\n{3}";
//string NodeInfoEndFormat = "\n\n[[Unity_Products:Amplify_Shader_Editor/Nodes | Back to Node List ]]\n[[Category:Nodes]][[Category:{0}]]\n\n\n";
//string NodeInfoBeginFormat = "{| cellpadding=\"10\"\n";
//string nodeInfoBodyFormat = "|- style=\"vertical-align:top;\"\n| http://amplify.pt/Nodes/{0}.jpg\n| [[Unity Products:Amplify Shader Editor/{1} | <span style=\"font-size: 120%;\"><span id=\"{2}\"></span>'''{2}'''<span> ]] <br> {3}\n";
//string NodeInfoEndFormat = "|}\n";
string nodesInfo = string.Empty;
BuildFullList( true );
CheckCommunityNodes();
var enumerator = m_currentCategories.GetEnumerator();
while( enumerator.MoveNext() )
{
var current = enumerator.Current;
if( fromCommunity && current.Value.HasCommunityData || !fromCommunity )
{
InitialCategories += string.Format( InitialCategoriesFormat, current.Key );
nodesInfo += string.Format( CurrentCategoryFormat, current.Key );
int count = current.Value.Contents.Count;
for( int i = 0; i < count; i++ )
{
if( ( fromCommunity && current.Value.Contents[ i ].NodeAttributes.FromCommunity )
|| !fromCommunity
//|| ( !fromCommunity && !current.Value.Contents[ i ].NodeAttributes.FromCommunity )
)
{
string nodeFullName = current.Value.Contents[ i ].Name;
string pictureFilename = UIUtils.ReplaceInvalidStrings( nodeFullName );
string pageFilename = UIUtils.RemoveWikiInvalidCharacters( pictureFilename );
pictureFilename = UIUtils.RemoveInvalidCharacters( pictureFilename );
string nodeDescription = current.Value.Contents[ i ].ItemUIContent.tooltip;
string communityText = string.Empty;
if( current.Value.Contents[ i ].NodeAttributes.FromCommunity )
communityText = "<small class=\"cardauthor\">( originally by "+ current.Value.Contents[ i ].NodeAttributes.Community + " )</small> ";
string nodeInfoBody = string.Format( nodeInfoBodyFormat, pictureFilename, pageFilename, nodeFullName, nodeDescription, communityText );
//string nodeInfoFoot = string.Format( NodesFootFormat, pageFilename );
nodesInfo += ( NodeInfoBeginFormat + nodeInfoBody + NodeInfoEndFormat );
//nodesInfo += ( NodeInfoBeginFormat + nodeInfoBody + string.Format( NodeInfoEndFormat, current.Key ) );
//if ( i != ( count - 1 ) )
//{
// nodesInfo += NodesFootFormatSep;
//}
}
}
nodesInfo += NodesFootFormatSep;
}
}
string finalText = noTOCHeader + nodesHeader + InitialCategories + nodesInfo + OverallFoot;
if( !System.IO.Directory.Exists( pathname ) )
{
System.IO.Directory.CreateDirectory( pathname );
}
// Save file
string nodesPathname = pathname + ( fromCommunity ? "AvailableNodesFromCommunity.txt" : "AvailableNodes.txt" );
Debug.Log( " Creating nodes file at " + nodesPathname );
IOUtils.SaveTextfileToDisk( finalText, nodesPathname, false );
BuildFullList( false );
}
public virtual bool CheckButton( GUIContent content, GUIStyle style, int buttonId )
{
if( buttonId != m_validButtonId )
{
GUILayout.Label( content, style );
return false;
}
return GUILayout.RepeatButton( content, style );
}
public void FillList( ref List<ContextMenuItem> list, bool forceAllItems )
{
List<ContextMenuItem> allList = forceAllItems ? ParentWindow.ContextMenuInstance.ItemFunctions : ParentWindow.ContextMenuInstance.MenuItems;
list.Clear();
int count = allList.Count;
for( int i = 0; i < count; i++ )
{
list.Add( allList[ i ] );
}
}
public Dictionary<string, PaletteFilterData> BuildFullList( bool forceAllNodes = false )
{
//Only need to build if search filter is active and list is set according to it
if( m_searchFilter.Length > 0 || !m_isActive || m_currentCategories.Count == 0 )
{
m_currentItems.Clear();
m_currentCategories.Clear();
List<ContextMenuItem> allItems = forceAllNodes ? ParentWindow.ContextMenuInstance.ItemFunctions : ParentWindow.ContextMenuInstance.MenuItems;
for( int i = 0; i < allItems.Count; i++ )
{
if( allItems[ i ].Name.IndexOf( m_searchFilter, StringComparison.InvariantCultureIgnoreCase ) >= 0 ||
allItems[ i ].Category.IndexOf( m_searchFilter, StringComparison.InvariantCultureIgnoreCase ) >= 0
)
{
m_currentItems.Add( allItems[ i ] );
if( !m_currentCategories.ContainsKey( allItems[ i ].Category ) )
{
m_currentCategories.Add( allItems[ i ].Category, new PaletteFilterData( m_defaultCategoryVisible ) );
//m_currentCategories[ allItems[ i ].Category ].HasCommunityData = allItems[ i ].NodeAttributes.FromCommunity || m_currentCategories[ allItems[ i ].Category ].HasCommunityData;
}
m_currentCategories[ allItems[ i ].Category ].Contents.Add( allItems[ i ] );
}
}
var categoryEnumerator = m_currentCategories.GetEnumerator();
while( categoryEnumerator.MoveNext() )
{
categoryEnumerator.Current.Value.Contents.Sort( ( x, y ) => x.CompareTo( y, false ) );
}
//mark to force update and take search filter into account
m_forceUpdate = true;
}
return m_currentCategories;
}
private bool IsItemVisible( float currPos )
{
if( ( currPos < m_currentScrollPos.y && ( currPos + ItemSize ) < m_currentScrollPos.y ) ||
( currPos > ( m_currentScrollPos.y + m_currScrollBarDims.y ) &&
( currPos + ItemSize ) > ( m_currentScrollPos.y + m_currScrollBarDims.y ) ) )
{
return false;
}
return true;
}
public override void Destroy()
{
base.Destroy();
//m_allItems = null;
m_currentItems.Clear();
m_currentItems = null;
m_currentCategories.Clear();
m_currentCategories = null;
OnPaletteNodeCreateEvt = null;
m_buttonStyle = null;
m_foldoutStyle = null;
}
//public void Clear() {
// m_allItems.Clear();
// m_allItems = new List<ContextMenuItem>();
//}
public bool ForceUpdate { get { return m_forceUpdate; } set { m_forceUpdate = value; } }
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: df4c2f840dca60a4cb118325ce2febfa
timeCreated: 1481126959
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,73 @@
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
namespace AmplifyShaderEditor
{
public class PalettePopUp
{
private const int DeltaX = 5;
private Rect m_areaSettings;
private Vector2 m_mouseDeltaPos = new Vector2( 10, -10 );
private bool m_isActive = false;
private GUIContent m_content;
private GUIStyle m_style;
private GUIStyle m_fontStyle;
private GUIContent m_labelContent;
public PalettePopUp()
{
m_content = new GUIContent( GUIContent.none );
m_areaSettings = new Rect( 0, 0, 100, 30 );
m_labelContent = new GUIContent( "Test Label" );
}
public void Activate( string label )
{
m_labelContent.text = label;
m_areaSettings.width = -1;
m_isActive = true;
}
public void Deactivate()
{
m_isActive = false;
}
public void Draw( Vector2 mousePos )
{
if ( m_style == null )
{
m_style = UIUtils.TextArea;
}
if ( m_fontStyle == null )
{
m_fontStyle = new GUIStyle( UIUtils.Label );
m_fontStyle.fontSize = 15;
}
if ( m_areaSettings.width < 0 )
{
m_areaSettings.width = m_fontStyle.CalcSize( m_labelContent ).x + 2 * DeltaX;
}
m_areaSettings.position = mousePos + m_mouseDeltaPos;
GUI.Label( m_areaSettings, m_content, m_style );
m_areaSettings.position += new Vector2( DeltaX,DeltaX);
GUI.Label( m_areaSettings, m_labelContent, m_fontStyle );
}
public void Destroy()
{
m_content = null;
m_style = null;
}
public bool IsActive
{
get { return m_isActive; }
}
}
}

Some files were not shown because too many files have changed in this diff Show More