fix:界面拉伸适配. add:支持cocos animation,spine,dragonbones等文件导入.
This commit is contained in:
parent
c4f716c8e9
commit
c232a91a41
23
README.md
23
README.md
@ -1,13 +1,12 @@
|
||||
# 仿Unity Animator可视化动画状态机编辑器
|
||||
# Cocos Animator
|
||||
一个用于Cocos Creator的可视化动画状态机编辑器。<br/>
|
||||
编辑器地址:https://leeyip.github.io/cocos-animator/
|
||||
|
||||
## TODO
|
||||
- [ ] 加载界面
|
||||
- [ ] 导入animation、spine、dragon bone文件生成状态节点
|
||||
- [x] 选中状态节点时,可更改transition排序,用于决定优先级(inspector中的transition显示需要做特殊表现用以表示此时可以进行排序)
|
||||
- [x] 状态节点与子状态机节点可以拖入到子状态机节点内,需解决跨越多层连线的问题
|
||||
- [x] 连向状态机的连线选项显示多层状态
|
||||
- [ ] 优化ui与代码、drawcall
|
||||
- [ ] *?每个状态机的entry和exit,状态机和状态一样也可以绑定逻辑脚本*
|
||||
## 目录
|
||||
|
||||
## 前言
|
||||
|
||||
## 使用
|
||||
|
||||
## 注意点
|
||||
- 参数名、子状态机名、状态名都不可重名
|
||||
@ -16,8 +15,8 @@
|
||||
- 当transition未勾选hasExitTime以及没有添加任何condition时,transition会被忽略
|
||||
- Parameters和Inspector两个界面如果内容超出,使用鼠标滚轮滚动,因为为了防止与拖拽行为产生冲突,触摸事件已被屏蔽
|
||||
|
||||
## 文件格式
|
||||
### 1. 编辑器工程文件格式
|
||||
## 数据格式
|
||||
### 1. 编辑器工程数据格式
|
||||
```
|
||||
{
|
||||
/** 编辑器版本号 */
|
||||
@ -121,7 +120,7 @@
|
||||
}
|
||||
```
|
||||
|
||||
### 2. runtime解析所需的文件格式
|
||||
### 2. runtime解析所需的数据格式
|
||||
```
|
||||
{
|
||||
parameters: [
|
||||
|
BIN
animator-editor/assets/res/texture/ui/add.png
Normal file
BIN
animator-editor/assets/res/texture/ui/add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 B |
34
animator-editor/assets/res/texture/ui/add.png.meta
Normal file
34
animator-editor/assets/res/texture/ui/add.png.meta
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"ver": "2.3.3",
|
||||
"uuid": "23ea6c0c-f477-404d-b16a-71bd87ca688c",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "point",
|
||||
"premultiplyAlpha": false,
|
||||
"genMipmaps": false,
|
||||
"packable": true,
|
||||
"platformSettings": {},
|
||||
"subMetas": {
|
||||
"add": {
|
||||
"ver": "1.0.4",
|
||||
"uuid": "6ac85e90-e7bb-4c26-83d1-63b3e2c67b5b",
|
||||
"rawTextureUuid": "23ea6c0c-f477-404d-b16a-71bd87ca688c",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 21,
|
||||
"height": 21,
|
||||
"rawWidth": 21,
|
||||
"rawHeight": 21,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,10 +24,10 @@
|
||||
"height": 250,
|
||||
"rawWidth": 250,
|
||||
"rawHeight": 250,
|
||||
"borderTop": 20,
|
||||
"borderBottom": 20,
|
||||
"borderLeft": 20,
|
||||
"borderRight": 20,
|
||||
"borderTop": 15,
|
||||
"borderBottom": 15,
|
||||
"borderLeft": 15,
|
||||
"borderRight": 15,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,20 +27,20 @@
|
||||
"__id__": 10
|
||||
},
|
||||
{
|
||||
"__id__": 20
|
||||
"__id__": 24
|
||||
},
|
||||
{
|
||||
"__id__": 32
|
||||
"__id__": 36
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 62
|
||||
"__id__": 66
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 63
|
||||
"__id__": 67
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -373,22 +373,25 @@
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 11
|
||||
},
|
||||
{
|
||||
"__id__": 15
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 15
|
||||
"__id__": 19
|
||||
},
|
||||
{
|
||||
"__id__": 16
|
||||
"__id__": 20
|
||||
},
|
||||
{
|
||||
"__id__": 17
|
||||
"__id__": 21
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 19
|
||||
"__id__": 23
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -439,7 +442,7 @@
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "New Label",
|
||||
"_name": "tri",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 10
|
||||
@ -458,6 +461,143 @@
|
||||
"__id__": 14
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 220,
|
||||
"g": 220,
|
||||
"b": 220,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 200,
|
||||
"height": 173
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
145,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
6.123233995736766e-17,
|
||||
0.08,
|
||||
0.08,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 180
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 11
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 1,
|
||||
"_target": null,
|
||||
"_alignFlags": 32,
|
||||
"_left": 0,
|
||||
"_right": 7,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 0,
|
||||
"_originalHeight": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 11
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d5067326-2ed3-4e1a-91a4-706a7e1ba65e"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__uuid__": "d2a69c7f-2a5f-40da-9dcc-ef17c9a856be"
|
||||
},
|
||||
"fileId": "27/82N9gVHJJF2/FU7Rh6Z",
|
||||
"sync": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "New Label",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 10
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 16
|
||||
},
|
||||
{
|
||||
"__id__": 17
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 18
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
@ -467,7 +607,7 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 153,
|
||||
"width": 130,
|
||||
"height": 40.32
|
||||
},
|
||||
"_anchorPoint": {
|
||||
@ -509,14 +649,14 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 11
|
||||
"__id__": 15
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 1,
|
||||
"_target": null,
|
||||
"_alignFlags": 40,
|
||||
"_left": 2,
|
||||
"_right": 5,
|
||||
"_right": 28,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
@ -536,7 +676,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 11
|
||||
"__id__": 15
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
@ -639,38 +779,40 @@
|
||||
"__id__": 10
|
||||
},
|
||||
"_enabled": true,
|
||||
"_normalMaterial": null,
|
||||
"_normalMaterial": {
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
},
|
||||
"_grayMaterial": null,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 18
|
||||
"__id__": 22
|
||||
}
|
||||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$transition": 0,
|
||||
"transition": 0,
|
||||
"_N$transition": 1,
|
||||
"transition": 1,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"r": 220,
|
||||
"g": 220,
|
||||
"b": 220,
|
||||
"a": 255
|
||||
},
|
||||
"_N$pressedColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 211,
|
||||
"g": 211,
|
||||
"b": 211,
|
||||
"r": 120,
|
||||
"g": 120,
|
||||
"b": 120,
|
||||
"a": 255
|
||||
},
|
||||
"pressedColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 211,
|
||||
"g": 211,
|
||||
"b": 211,
|
||||
"r": 120,
|
||||
"g": 120,
|
||||
"b": 120,
|
||||
"a": 255
|
||||
},
|
||||
"_N$hoverColor": {
|
||||
@ -689,9 +831,9 @@
|
||||
},
|
||||
"_N$disabledColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 124,
|
||||
"g": 124,
|
||||
"b": 124,
|
||||
"r": 120,
|
||||
"g": 120,
|
||||
"b": 120,
|
||||
"a": 255
|
||||
},
|
||||
"_N$normalSprite": null,
|
||||
@ -700,7 +842,9 @@
|
||||
"_N$hoverSprite": null,
|
||||
"hoverSprite": null,
|
||||
"_N$disabledSprite": null,
|
||||
"_N$target": null,
|
||||
"_N$target": {
|
||||
"__id__": 11
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -732,24 +876,24 @@
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 21
|
||||
},
|
||||
{
|
||||
"__id__": 25
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 28
|
||||
},
|
||||
{
|
||||
"__id__": 29
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 32
|
||||
},
|
||||
{
|
||||
"__id__": 33
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 31
|
||||
"__id__": 35
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -803,20 +947,20 @@
|
||||
"_name": "bg",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 20
|
||||
"__id__": 24
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 22
|
||||
"__id__": 26
|
||||
},
|
||||
{
|
||||
"__id__": 23
|
||||
"__id__": 27
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 24
|
||||
"__id__": 28
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -870,7 +1014,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 21
|
||||
"__id__": 25
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
@ -902,7 +1046,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 21
|
||||
"__id__": 25
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 1,
|
||||
@ -940,17 +1084,17 @@
|
||||
"_name": "lab",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 20
|
||||
"__id__": 24
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 26
|
||||
"__id__": 30
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 27
|
||||
"__id__": 31
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -1004,7 +1148,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 25
|
||||
"__id__": 29
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
@ -1045,7 +1189,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 20
|
||||
"__id__": 24
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 1,
|
||||
@ -1072,7 +1216,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 20
|
||||
"__id__": 24
|
||||
},
|
||||
"_enabled": true,
|
||||
"_normalMaterial": null,
|
||||
@ -1081,7 +1225,7 @@
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 30
|
||||
"__id__": 34
|
||||
}
|
||||
],
|
||||
"_N$interactable": true,
|
||||
@ -1169,20 +1313,20 @@
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 33
|
||||
"__id__": 37
|
||||
},
|
||||
{
|
||||
"__id__": 50
|
||||
"__id__": 54
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 60
|
||||
"__id__": 64
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 61
|
||||
"__id__": 65
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -1236,27 +1380,27 @@
|
||||
"_name": "number",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 32
|
||||
"__id__": 36
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 34
|
||||
},
|
||||
{
|
||||
"__id__": 38
|
||||
},
|
||||
{
|
||||
"__id__": 42
|
||||
},
|
||||
{
|
||||
"__id__": 46
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 46
|
||||
"__id__": 50
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 49
|
||||
"__id__": 53
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -1310,20 +1454,20 @@
|
||||
"_name": "BACKGROUND_SPRITE",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 33
|
||||
"__id__": 37
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 35
|
||||
"__id__": 39
|
||||
},
|
||||
{
|
||||
"__id__": 36
|
||||
"__id__": 40
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 37
|
||||
"__id__": 41
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -1377,7 +1521,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 34
|
||||
"__id__": 38
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
@ -1409,7 +1553,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 34
|
||||
"__id__": 38
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 0,
|
||||
@ -1447,20 +1591,20 @@
|
||||
"_name": "TEXT_LABEL",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 33
|
||||
"__id__": 37
|
||||
},
|
||||
"_children": [],
|
||||
"_active": false,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 39
|
||||
"__id__": 43
|
||||
},
|
||||
{
|
||||
"__id__": 40
|
||||
"__id__": 44
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 41
|
||||
"__id__": 45
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -1514,7 +1658,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 38
|
||||
"__id__": 42
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [],
|
||||
@ -1540,7 +1684,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 38
|
||||
"__id__": 42
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 0,
|
||||
@ -1578,20 +1722,20 @@
|
||||
"_name": "PLACEHOLDER_LABEL",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 33
|
||||
"__id__": 37
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 43
|
||||
"__id__": 47
|
||||
},
|
||||
{
|
||||
"__id__": 44
|
||||
"__id__": 48
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 45
|
||||
"__id__": 49
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -1645,7 +1789,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 42
|
||||
"__id__": 46
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
@ -1675,7 +1819,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 42
|
||||
"__id__": 46
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 0,
|
||||
@ -1713,7 +1857,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 33
|
||||
"__id__": 37
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
@ -1723,24 +1867,24 @@
|
||||
"_tabIndex": 0,
|
||||
"editingDidBegan": [
|
||||
{
|
||||
"__id__": 47
|
||||
"__id__": 51
|
||||
}
|
||||
],
|
||||
"textChanged": [
|
||||
{
|
||||
"__id__": 48
|
||||
"__id__": 52
|
||||
}
|
||||
],
|
||||
"editingDidEnded": [],
|
||||
"editingReturn": [],
|
||||
"_N$textLabel": {
|
||||
"__id__": 39
|
||||
},
|
||||
"_N$placeholderLabel": {
|
||||
"__id__": 43
|
||||
},
|
||||
"_N$placeholderLabel": {
|
||||
"__id__": 47
|
||||
},
|
||||
"_N$background": {
|
||||
"__id__": 35
|
||||
"__id__": 39
|
||||
},
|
||||
"_N$inputFlag": 5,
|
||||
"_N$inputMode": 6,
|
||||
@ -1783,24 +1927,24 @@
|
||||
"_name": "boolean",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 32
|
||||
"__id__": 36
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 51
|
||||
"__id__": 55
|
||||
},
|
||||
{
|
||||
"__id__": 54
|
||||
"__id__": 58
|
||||
}
|
||||
],
|
||||
"_active": false,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 57
|
||||
"__id__": 61
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 59
|
||||
"__id__": 63
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -1854,17 +1998,17 @@
|
||||
"_name": "Background",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 50
|
||||
"__id__": 54
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 52
|
||||
"__id__": 56
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 53
|
||||
"__id__": 57
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -1918,7 +2062,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 51
|
||||
"__id__": 55
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
@ -1961,17 +2105,17 @@
|
||||
"_name": "checkmark",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 50
|
||||
"__id__": 54
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 55
|
||||
"__id__": 59
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 56
|
||||
"__id__": 60
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -2025,7 +2169,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 54
|
||||
"__id__": 58
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
@ -2068,7 +2212,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 50
|
||||
"__id__": 54
|
||||
},
|
||||
"_enabled": true,
|
||||
"_normalMaterial": {
|
||||
@ -2131,16 +2275,16 @@
|
||||
"hoverSprite": null,
|
||||
"_N$disabledSprite": null,
|
||||
"_N$target": {
|
||||
"__id__": 51
|
||||
"__id__": 55
|
||||
},
|
||||
"_N$isChecked": true,
|
||||
"toggleGroup": null,
|
||||
"checkMark": {
|
||||
"__id__": 55
|
||||
"__id__": 59
|
||||
},
|
||||
"checkEvents": [
|
||||
{
|
||||
"__id__": 58
|
||||
"__id__": 62
|
||||
}
|
||||
],
|
||||
"_id": ""
|
||||
@ -2171,7 +2315,7 @@
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 32
|
||||
"__id__": 36
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 1,
|
||||
@ -2216,13 +2360,13 @@
|
||||
"__id__": 2
|
||||
},
|
||||
"ParamName": {
|
||||
"__id__": 13
|
||||
"__id__": 17
|
||||
},
|
||||
"LogicNode": {
|
||||
"__id__": 20
|
||||
"__id__": 24
|
||||
},
|
||||
"ValueNode": {
|
||||
"__id__": 32
|
||||
"__id__": 36
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
|
@ -24,17 +24,17 @@
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 5
|
||||
},
|
||||
{
|
||||
"__id__": 7
|
||||
"__id__": 6
|
||||
},
|
||||
{
|
||||
"__id__": 8
|
||||
},
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 9
|
||||
"__id__": 10
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -95,10 +95,13 @@
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 4
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 4
|
||||
"__id__": 5
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -147,6 +150,33 @@
|
||||
"groupIndex": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 1,
|
||||
"_target": null,
|
||||
"_alignFlags": 40,
|
||||
"_left": 5,
|
||||
"_right": 5,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 200,
|
||||
"_originalHeight": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
@ -204,7 +234,7 @@
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 6
|
||||
"__id__": 7
|
||||
}
|
||||
],
|
||||
"_N$interactable": true,
|
||||
@ -325,7 +355,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"NameLabel": {
|
||||
"__id__": 3
|
||||
"__id__": 4
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
|
@ -397,8 +397,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 35,
|
||||
"height": 35
|
||||
"width": 30,
|
||||
"height": 30
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@ -553,7 +553,7 @@
|
||||
"_target": null,
|
||||
"_alignFlags": 32,
|
||||
"_left": 0,
|
||||
"_right": 12.5,
|
||||
"_right": 15,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
@ -576,7 +576,9 @@
|
||||
"__id__": 10
|
||||
},
|
||||
"_enabled": true,
|
||||
"_normalMaterial": null,
|
||||
"_normalMaterial": {
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
},
|
||||
"_grayMaterial": null,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.2,
|
||||
@ -587,27 +589,27 @@
|
||||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$transition": 0,
|
||||
"transition": 0,
|
||||
"_N$transition": 1,
|
||||
"transition": 1,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"r": 220,
|
||||
"g": 220,
|
||||
"b": 220,
|
||||
"a": 255
|
||||
},
|
||||
"_N$pressedColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 211,
|
||||
"g": 211,
|
||||
"b": 211,
|
||||
"r": 120,
|
||||
"g": 120,
|
||||
"b": 120,
|
||||
"a": 255
|
||||
},
|
||||
"pressedColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 211,
|
||||
"g": 211,
|
||||
"b": 211,
|
||||
"r": 120,
|
||||
"g": 120,
|
||||
"b": 120,
|
||||
"a": 255
|
||||
},
|
||||
"_N$hoverColor": {
|
||||
@ -626,9 +628,9 @@
|
||||
},
|
||||
"_N$disabledColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 124,
|
||||
"g": 124,
|
||||
"b": 124,
|
||||
"r": 120,
|
||||
"g": 120,
|
||||
"b": 120,
|
||||
"a": 255
|
||||
},
|
||||
"_N$normalSprite": null,
|
||||
@ -637,7 +639,9 @@
|
||||
"_N$hoverSprite": null,
|
||||
"hoverSprite": null,
|
||||
"_N$disabledSprite": null,
|
||||
"_N$target": null,
|
||||
"_N$target": {
|
||||
"__id__": 11
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
@ -19,22 +19,22 @@
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 2
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 8
|
||||
"__id__": 6
|
||||
},
|
||||
{
|
||||
"__id__": 10
|
||||
"__id__": 7
|
||||
},
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 11
|
||||
"__id__": 10
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -83,113 +83,6 @@
|
||||
"groupIndex": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "bg",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 3
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 4
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 145,
|
||||
"height": 40
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "9cc36e23-5b41-44ad-8512-a0a6bbf8e7b1"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__uuid__": "bd11cbb4-2878-4444-a558-63960f0ca931"
|
||||
},
|
||||
"fileId": "9eZGS5RWpKlachTtOIsQ4f",
|
||||
"sync": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "New Label",
|
||||
@ -201,11 +94,14 @@
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 6
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 4
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 7
|
||||
"__id__": 5
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -217,7 +113,7 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 145,
|
||||
"width": 135,
|
||||
"height": 50.4
|
||||
},
|
||||
"_anchorPoint": {
|
||||
@ -254,12 +150,39 @@
|
||||
"groupIndex": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 1,
|
||||
"_target": null,
|
||||
"_alignFlags": 40,
|
||||
"_left": 5,
|
||||
"_right": 5,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 135,
|
||||
"_originalHeight": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 5
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
@ -295,6 +218,38 @@
|
||||
"fileId": "4d6ZMnzSdJHauzrxuxF0uV",
|
||||
"sync": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "9cc36e23-5b41-44ad-8512-a0a6bbf8e7b1"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Button",
|
||||
"_name": "",
|
||||
@ -311,7 +266,7 @@
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 9
|
||||
"__id__": 8
|
||||
}
|
||||
],
|
||||
"_N$interactable": true,
|
||||
@ -366,9 +321,7 @@
|
||||
"_N$hoverSprite": null,
|
||||
"hoverSprite": null,
|
||||
"_N$disabledSprite": null,
|
||||
"_N$target": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_N$target": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@ -390,7 +343,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"ParamName": {
|
||||
"__id__": 6
|
||||
"__id__": 4
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
|
@ -1,4 +1,6 @@
|
||||
import Setting from "../../editor/Setting";
|
||||
import Events, { EventName } from "../util/Events";
|
||||
import Tool from "../util/Tool";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ -36,7 +38,7 @@ export default class ResizeArea extends cc.Component {
|
||||
this.Target.updateAlignment();
|
||||
|
||||
Events.emit(EventName.RESIZE, this.Target.node);
|
||||
this.updateWidget(this.Target.node);
|
||||
Setting.save();
|
||||
}
|
||||
|
||||
private onTouchStart(event: cc.Event.EventTouch) {
|
||||
@ -61,12 +63,4 @@ export default class ResizeArea extends cc.Component {
|
||||
private onMouseLeave(event: cc.Event.EventMouse) {
|
||||
this._canvas.style.cursor = 'default ';
|
||||
}
|
||||
|
||||
private updateWidget(node: cc.Node) {
|
||||
node.children.forEach((c) => {
|
||||
let widget = c.getComponent(cc.Widget);
|
||||
widget && widget.updateAlignment();
|
||||
this.updateWidget(c);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -105,4 +105,20 @@ export default class Tool {
|
||||
arr.splice(idx, 1);
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归遍历所有子节点并更新widget组件
|
||||
* @param node 目标节点,需遍历其子节点
|
||||
* @param ignoreList 忽略节点,这些节点的子节点跳过遍历
|
||||
*/
|
||||
public static updateWidget(node: cc.Node, ...ignoreList: cc.Node[]) {
|
||||
node.children.forEach((c) => {
|
||||
let widget = c.getComponent(cc.Widget);
|
||||
widget && widget.updateAlignment();
|
||||
if (this.arrayHas(ignoreList, c)) {
|
||||
return;
|
||||
}
|
||||
this.updateWidget(c, ...ignoreList);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import Tool from "../common/util/Tool";
|
||||
import FsmCtr from "./fsm/FsmCtr";
|
||||
import InspectorCtr from "./inspector/InspectorCtr";
|
||||
import Menu from "./menu/Menu";
|
||||
import ParamCtr from "./parameters/ParamCtr";
|
||||
import Setting from "./Setting";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ -9,7 +11,7 @@ const { ccclass, property } = cc._decorator;
|
||||
export default class Editor extends cc.Component {
|
||||
@property(FsmCtr) Fsm: FsmCtr = null;
|
||||
@property(InspectorCtr) Inspector: InspectorCtr = null;
|
||||
@property(ParamCtr) ParamCtr: ParamCtr = null;
|
||||
@property(ParamCtr) Parameters: ParamCtr = null;
|
||||
@property(Menu) Menu: Menu = null;
|
||||
|
||||
public static Inst: Editor = null;
|
||||
@ -18,6 +20,15 @@ export default class Editor extends cc.Component {
|
||||
private _keySet: Set<cc.macro.KEY> = new Set();
|
||||
|
||||
protected onLoad() {
|
||||
// 初始化界面宽度
|
||||
Setting.read();
|
||||
this.Inspector.node.width = Setting.inspectorWidth;
|
||||
this.Inspector.getComponent(cc.Widget).updateAlignment();
|
||||
Tool.updateWidget(this.Inspector.node);
|
||||
this.Parameters.node.width = Setting.parametersWidth;
|
||||
this.Parameters.getComponent(cc.Widget).updateAlignment();
|
||||
Tool.updateWidget(this.Parameters.node);
|
||||
|
||||
cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
|
||||
cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
|
||||
}
|
||||
@ -33,8 +44,8 @@ export default class Editor extends cc.Component {
|
||||
switch (event.keyCode) {
|
||||
case cc.macro.KEY.s:
|
||||
if (this._keySet.has(cc.macro.KEY.ctrl)) {
|
||||
// 保存工程文件
|
||||
this.saveProject();
|
||||
// 导出工程文件
|
||||
this.exportProject();
|
||||
}
|
||||
break;
|
||||
case cc.macro.KEY.e:
|
||||
@ -56,15 +67,15 @@ export default class Editor extends cc.Component {
|
||||
this._keySet.delete(event.keyCode);
|
||||
}
|
||||
|
||||
private saveProject() {
|
||||
private exportProject() {
|
||||
let data: any = this.Fsm.exportProject();
|
||||
data.parameters = this.ParamCtr.export();
|
||||
data.parameters = this.Parameters.export();
|
||||
this.save('animator.json', data);
|
||||
}
|
||||
|
||||
private exportRuntimeData() {
|
||||
let data: any = this.Fsm.exportRuntimeData();
|
||||
data.parameters = this.ParamCtr.export();
|
||||
data.parameters = this.Parameters.export();
|
||||
this.save('runtimeData.json', data);
|
||||
}
|
||||
|
||||
@ -83,16 +94,4 @@ export default class Editor extends cc.Component {
|
||||
// 移除
|
||||
document.body.removeChild(eleLink);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入工程文件
|
||||
*/
|
||||
public importProject(data: any) {
|
||||
if (!data.hasOwnProperty('animator')) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.ParamCtr.import(data.parameters);
|
||||
this.Fsm.importProject(data);
|
||||
}
|
||||
}
|
||||
|
45
animator-editor/assets/script/editor/Setting.ts
Normal file
45
animator-editor/assets/script/editor/Setting.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import Editor from "./Editor";
|
||||
|
||||
/**
|
||||
* 本地设置
|
||||
*/
|
||||
export default class Setting {
|
||||
private static _inspectorWidth: number = 400;
|
||||
public static get inspectorWidth() { return this._inspectorWidth; }
|
||||
|
||||
private static _parametersWidth: number = 300;
|
||||
public static get parametersWidth() { return this._parametersWidth; }
|
||||
|
||||
/**
|
||||
* 初始化读取数据
|
||||
*/
|
||||
public static read() {
|
||||
let str = cc.sys.localStorage.getItem('setting');
|
||||
if (!str) {
|
||||
return;
|
||||
}
|
||||
let data = JSON.parse(str);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
if (data.inspectorWidth) {
|
||||
this._inspectorWidth = data.inspectorWidth;
|
||||
}
|
||||
if (data.parametersWidth) {
|
||||
this._parametersWidth = data.parametersWidth;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
*/
|
||||
public static save() {
|
||||
this._inspectorWidth = Editor.Inst.Inspector.node.width;
|
||||
this._parametersWidth = Editor.Inst.Parameters.node.width;
|
||||
let data = {
|
||||
inspectorWidth: this._inspectorWidth,
|
||||
parametersWidth: this._parametersWidth
|
||||
};
|
||||
cc.sys.localStorage.setItem('setting', JSON.stringify(data));
|
||||
}
|
||||
}
|
9
animator-editor/assets/script/editor/Setting.ts.meta
Normal file
9
animator-editor/assets/script/editor/Setting.ts.meta
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "e82bc412-96df-4bfc-a190-2cb173908cbd",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import Events, { EventName, preloadEvent } from "../../common/util/Events";
|
||||
import Tool from "../../common/util/Tool";
|
||||
import { ANIMATOR_VERSION } from "../../constant/BaseConst";
|
||||
import Condition from "../data/Condition";
|
||||
import State from "../data/State";
|
||||
@ -58,210 +59,6 @@ export default class FsmCtr extends cc.Component {
|
||||
}
|
||||
}
|
||||
|
||||
//#region import and export
|
||||
private importTransitions(transitionsData: any[], state: State, stateMap: Map<string, State>, paramMap: Map<string, ParamItem>) {
|
||||
transitionsData.forEach((e) => {
|
||||
let toState: State = stateMap.get(e.toState);
|
||||
let transition: Transition = state.addTransition(toState);
|
||||
transition.hasExitTime = e.hasExitTime;
|
||||
e.conditions.forEach((cData) => {
|
||||
let paramItem = paramMap.get(cData.param);
|
||||
let condition: Condition = transition.addCondition(paramItem);
|
||||
condition.value = cData.value;
|
||||
condition.logic = cData.logic;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private importSubState(upData: any, upMachine: StateMachine, stateDataMap: Map<string, any>, stateMap: Map<string, State>, paramMap: Map<string, ParamItem>) {
|
||||
upData.subStates.forEach((name: string) => {
|
||||
let state = new State(upMachine, false);
|
||||
stateMap.set(name, state);
|
||||
let data = stateDataMap.get(name);
|
||||
state.setPosition(data.position[0], data.position[1]);
|
||||
state.name = data.state;
|
||||
state.motion = data.motion;
|
||||
state.speed = data.speed;
|
||||
state.multiplierParam = paramMap.get(data.multiplier) || null;
|
||||
state.loop = data.loop;
|
||||
|
||||
upMachine.add(state);
|
||||
});
|
||||
}
|
||||
|
||||
private importSubMachine(upData: any, upMachine: StateMachine, subMachineDataMap: Map<string, any>, subMachineMap: Map<string, StateMachine>, stateDataMap: Map<string, any>, stateMap: Map<string, State>, paramMap: Map<string, ParamItem>) {
|
||||
upData.subStateMachines.forEach((name: string) => {
|
||||
let stateMachine = new StateMachine(upMachine);
|
||||
subMachineMap.set(name, stateMachine);
|
||||
let data = subMachineDataMap.get(name);
|
||||
stateMachine.setLayerPos(data.layerPos[0], data.layerPos[1]);
|
||||
stateMachine.setLayerScale(data.layerScale);
|
||||
stateMachine.setAnyStatePos(data.anyStatePos[0], data.anyStatePos[1]);
|
||||
stateMachine.name = data.name;
|
||||
stateMachine.setPosition(data.position[0], data.position[1]);
|
||||
stateMachine.setUpStateMachinePos(data.upStateMachinePos[0], data.upStateMachinePos[1]);
|
||||
|
||||
upMachine.add(stateMachine);
|
||||
|
||||
this.importSubState(data, stateMachine, stateDataMap, stateMap, paramMap);
|
||||
this.importSubMachine(data, stateMachine, subMachineDataMap, subMachineMap, stateDataMap, stateMap, paramMap);
|
||||
});
|
||||
}
|
||||
|
||||
private exportAllSubMachine(arr: any[], stateMachine: StateMachine) {
|
||||
stateMachine.subStateMachines.forEach((sub) => {
|
||||
let data = {
|
||||
layerPos: [sub.layerPos.x, sub.layerPos.y],
|
||||
layerScale: sub.layerScale,
|
||||
anyStatePos: [sub.anyStatePos.x, sub.anyStatePos.y],
|
||||
name: sub.name,
|
||||
position: [sub.position.x, sub.position.y],
|
||||
upStateMachine: sub.upStateMachine.name,
|
||||
upStateMachinePos: [sub.upStateMachinePos.x, sub.upStateMachinePos.y],
|
||||
subStates: [],
|
||||
subStateMachines: [],
|
||||
}
|
||||
sub.subStates.forEach((e) => {
|
||||
data.subStates.push(e.name);
|
||||
});
|
||||
sub.subStateMachines.forEach((e) => {
|
||||
data.subStateMachines.push(e.name);
|
||||
});
|
||||
arr.push(data);
|
||||
this.exportAllSubMachine(arr, sub);
|
||||
});
|
||||
}
|
||||
|
||||
private exportAllState(arr: any[], stateMachine: StateMachine, isRuntimeData: boolean = false) {
|
||||
stateMachine.subStates.forEach((e) => {
|
||||
let data = null;
|
||||
if (isRuntimeData) {
|
||||
data = {
|
||||
state: e.name,
|
||||
motion: e.motion,
|
||||
speed: e.speed,
|
||||
multiplier: e.getMultiplierName(),
|
||||
loop: e.loop,
|
||||
transitions: e.getAllTransitionData()
|
||||
}
|
||||
} else {
|
||||
data = {
|
||||
position: [e.position.x, e.position.y],
|
||||
upStateMachine: e.upStateMachine.name,
|
||||
state: e.name,
|
||||
motion: e.motion,
|
||||
speed: e.speed,
|
||||
multiplier: e.getMultiplierName(),
|
||||
loop: e.loop,
|
||||
transitions: e.getAllTransitionData()
|
||||
}
|
||||
}
|
||||
arr.push(data);
|
||||
});
|
||||
stateMachine.subStateMachines.forEach((sub) => {
|
||||
this.exportAllState(arr, sub);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入工程数据
|
||||
*/
|
||||
public importProject(data: any) {
|
||||
let paramMap: Map<string, ParamItem> = Editor.Inst.ParamCtr.getParamMap();
|
||||
|
||||
let mainStateMachineData = data.mainStateMachine;
|
||||
let subStateMachinesData = data.subStateMachines;
|
||||
let defaultStateData: string = data.defaultState;
|
||||
let anyStateData = data.anyState;
|
||||
let statesData = data.states;
|
||||
|
||||
let stateDataMap: Map<string, any> = new Map();
|
||||
statesData.forEach((e: any) => { stateDataMap.set(e.state, e); });
|
||||
let stateMap: Map<string, State> = new Map();
|
||||
|
||||
let subMachineDataMap: Map<string, any> = new Map();
|
||||
subStateMachinesData.forEach((e: any) => { subMachineDataMap.set(e.name, e) });
|
||||
let subMachineMap: Map<string, StateMachine> = new Map();
|
||||
|
||||
let main = this.MachineLayer.mainStateMachine;
|
||||
main.setLayerPos(mainStateMachineData.layerPos[0], mainStateMachineData.layerPos[1]);
|
||||
main.setLayerScale(mainStateMachineData.layerScale);
|
||||
main.setAnyStatePos(mainStateMachineData.anyStatePos[0], mainStateMachineData.anyStatePos[1]);
|
||||
this.importSubState(mainStateMachineData, main, stateDataMap, stateMap, paramMap);
|
||||
this.importSubMachine(mainStateMachineData, main, subMachineDataMap, subMachineMap, stateDataMap, stateMap, paramMap);
|
||||
|
||||
if (stateMap.has(defaultStateData))
|
||||
this.MachineLayer.defaultState = stateMap.get(defaultStateData);
|
||||
|
||||
this.importTransitions(anyStateData.transitions, this.MachineLayer.anyState.state, stateMap, paramMap);
|
||||
statesData.forEach((e: any) => {
|
||||
let state: State = stateMap.get(e.state);
|
||||
if (!state) {
|
||||
cc.error('error');
|
||||
}
|
||||
this.importTransitions(e.transitions, state, stateMap, paramMap);
|
||||
});
|
||||
|
||||
this.MachineLayer.setCurStateMachine();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出工程数据
|
||||
*/
|
||||
public exportProject() {
|
||||
let main = this.MachineLayer.mainStateMachine;
|
||||
let animator = ANIMATOR_VERSION;
|
||||
let mainStateMachine = {
|
||||
layerPos: [main.layerPos.x, main.layerPos.y],
|
||||
layerScale: main.layerScale,
|
||||
anyStatePos: [main.anyStatePos.x, main.anyStatePos.y],
|
||||
subStates: [],
|
||||
subStateMachines: [],
|
||||
};
|
||||
main.subStates.forEach((e) => {
|
||||
mainStateMachine.subStates.push(e.name);
|
||||
});
|
||||
main.subStateMachines.forEach((e) => {
|
||||
mainStateMachine.subStateMachines.push(e.name);
|
||||
});
|
||||
let subStateMachines = [];
|
||||
this.exportAllSubMachine(subStateMachines, main);
|
||||
|
||||
let defaultState: string = this.MachineLayer.defaultState ? this.MachineLayer.defaultState.name : '';
|
||||
let anyState = {
|
||||
transitions: this.MachineLayer.anyState.state.getAllTransitionData()
|
||||
};
|
||||
let states = [];
|
||||
this.exportAllState(states, main);
|
||||
return {
|
||||
animator: animator,
|
||||
mainStateMachine: mainStateMachine,
|
||||
subStateMachines: subStateMachines,
|
||||
defaultState: defaultState,
|
||||
anyState: anyState,
|
||||
states: states
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出runtime数据
|
||||
*/
|
||||
public exportRuntimeData() {
|
||||
let main = this.MachineLayer.mainStateMachine;
|
||||
let defaultState: string = this.MachineLayer.defaultState ? this.MachineLayer.defaultState.name : '';
|
||||
let anyState = {
|
||||
transitions: this.MachineLayer.anyState.state.getAllTransitionData()
|
||||
};
|
||||
let states = [];
|
||||
this.exportAllState(states, main, true);
|
||||
return {
|
||||
defaultState: defaultState,
|
||||
anyState: anyState,
|
||||
states: states
|
||||
};
|
||||
}
|
||||
//#endregion
|
||||
|
||||
/**
|
||||
* 按下鼠标左键的处理
|
||||
*/
|
||||
@ -604,4 +401,253 @@ export default class FsmCtr extends cc.Component {
|
||||
this.setCurStateMachine(stateMachine);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region import and export
|
||||
private importTransitions(transitionsData: any[], state: State, stateMap: Map<string, State>, paramMap: Map<string, ParamItem>) {
|
||||
transitionsData.forEach((e) => {
|
||||
let toState: State = stateMap.get(e.toState);
|
||||
let transition: Transition = state.addTransition(toState);
|
||||
transition.hasExitTime = e.hasExitTime;
|
||||
e.conditions.forEach((cData) => {
|
||||
let paramItem = paramMap.get(cData.param);
|
||||
let condition: Condition = transition.addCondition(paramItem);
|
||||
condition.value = cData.value;
|
||||
condition.logic = cData.logic;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private importSubState(upData: any, upMachine: StateMachine, stateDataMap: Map<string, any>, stateMap: Map<string, State>, paramMap: Map<string, ParamItem>) {
|
||||
upData.subStates.forEach((name: string) => {
|
||||
let state = new State(upMachine, false);
|
||||
stateMap.set(name, state);
|
||||
let data = stateDataMap.get(name);
|
||||
state.setPosition(data.position[0], data.position[1]);
|
||||
state.name = data.state;
|
||||
state.motion = data.motion;
|
||||
state.speed = data.speed;
|
||||
state.multiplierParam = paramMap.get(data.multiplier) || null;
|
||||
state.loop = data.loop;
|
||||
|
||||
upMachine.add(state);
|
||||
});
|
||||
}
|
||||
|
||||
private importSubMachine(upData: any, upMachine: StateMachine, subMachineDataMap: Map<string, any>, subMachineMap: Map<string, StateMachine>, stateDataMap: Map<string, any>, stateMap: Map<string, State>, paramMap: Map<string, ParamItem>) {
|
||||
upData.subStateMachines.forEach((name: string) => {
|
||||
let stateMachine = new StateMachine(upMachine);
|
||||
subMachineMap.set(name, stateMachine);
|
||||
let data = subMachineDataMap.get(name);
|
||||
stateMachine.setLayerPos(data.layerPos[0], data.layerPos[1]);
|
||||
stateMachine.setLayerScale(data.layerScale);
|
||||
stateMachine.setAnyStatePos(data.anyStatePos[0], data.anyStatePos[1]);
|
||||
stateMachine.name = data.name;
|
||||
stateMachine.setPosition(data.position[0], data.position[1]);
|
||||
stateMachine.setUpStateMachinePos(data.upStateMachinePos[0], data.upStateMachinePos[1]);
|
||||
|
||||
upMachine.add(stateMachine);
|
||||
|
||||
this.importSubState(data, stateMachine, stateDataMap, stateMap, paramMap);
|
||||
this.importSubMachine(data, stateMachine, subMachineDataMap, subMachineMap, stateDataMap, stateMap, paramMap);
|
||||
});
|
||||
}
|
||||
|
||||
private exportAllSubMachine(arr: any[], stateMachine: StateMachine) {
|
||||
stateMachine.subStateMachines.forEach((sub) => {
|
||||
let data = {
|
||||
layerPos: [sub.layerPos.x, sub.layerPos.y],
|
||||
layerScale: sub.layerScale,
|
||||
anyStatePos: [sub.anyStatePos.x, sub.anyStatePos.y],
|
||||
name: sub.name,
|
||||
position: [sub.position.x, sub.position.y],
|
||||
upStateMachine: sub.upStateMachine.name,
|
||||
upStateMachinePos: [sub.upStateMachinePos.x, sub.upStateMachinePos.y],
|
||||
subStates: [],
|
||||
subStateMachines: [],
|
||||
}
|
||||
sub.subStates.forEach((e) => {
|
||||
data.subStates.push(e.name);
|
||||
});
|
||||
sub.subStateMachines.forEach((e) => {
|
||||
data.subStateMachines.push(e.name);
|
||||
});
|
||||
arr.push(data);
|
||||
this.exportAllSubMachine(arr, sub);
|
||||
});
|
||||
}
|
||||
|
||||
private exportAllState(arr: any[], stateMachine: StateMachine, isRuntimeData: boolean = false) {
|
||||
stateMachine.subStates.forEach((e) => {
|
||||
let data = null;
|
||||
if (isRuntimeData) {
|
||||
data = {
|
||||
state: e.name,
|
||||
motion: e.motion,
|
||||
speed: e.speed,
|
||||
multiplier: e.getMultiplierName(),
|
||||
loop: e.loop,
|
||||
transitions: e.getAllTransitionData()
|
||||
}
|
||||
} else {
|
||||
data = {
|
||||
position: [e.position.x, e.position.y],
|
||||
upStateMachine: e.upStateMachine.name,
|
||||
state: e.name,
|
||||
motion: e.motion,
|
||||
speed: e.speed,
|
||||
multiplier: e.getMultiplierName(),
|
||||
loop: e.loop,
|
||||
transitions: e.getAllTransitionData()
|
||||
}
|
||||
}
|
||||
arr.push(data);
|
||||
});
|
||||
stateMachine.subStateMachines.forEach((sub) => {
|
||||
this.exportAllState(arr, sub);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入工程数据
|
||||
*/
|
||||
public importProject(data: any) {
|
||||
let paramMap: Map<string, ParamItem> = Editor.Inst.Parameters.getParamMap();
|
||||
|
||||
let mainStateMachineData = data.mainStateMachine;
|
||||
let subStateMachinesData = data.subStateMachines;
|
||||
let defaultStateData: string = data.defaultState;
|
||||
let anyStateData = data.anyState;
|
||||
let statesData = data.states;
|
||||
|
||||
let stateDataMap: Map<string, any> = new Map();
|
||||
statesData.forEach((e: any) => { stateDataMap.set(e.state, e); });
|
||||
let stateMap: Map<string, State> = new Map();
|
||||
|
||||
let subMachineDataMap: Map<string, any> = new Map();
|
||||
subStateMachinesData.forEach((e: any) => { subMachineDataMap.set(e.name, e) });
|
||||
let subMachineMap: Map<string, StateMachine> = new Map();
|
||||
|
||||
let main = this.MachineLayer.mainStateMachine;
|
||||
main.setLayerPos(mainStateMachineData.layerPos[0], mainStateMachineData.layerPos[1]);
|
||||
main.setLayerScale(mainStateMachineData.layerScale);
|
||||
main.setAnyStatePos(mainStateMachineData.anyStatePos[0], mainStateMachineData.anyStatePos[1]);
|
||||
this.importSubState(mainStateMachineData, main, stateDataMap, stateMap, paramMap);
|
||||
this.importSubMachine(mainStateMachineData, main, subMachineDataMap, subMachineMap, stateDataMap, stateMap, paramMap);
|
||||
|
||||
if (stateMap.has(defaultStateData))
|
||||
this.MachineLayer.defaultState = stateMap.get(defaultStateData);
|
||||
|
||||
this.importTransitions(anyStateData.transitions, this.MachineLayer.anyState.state, stateMap, paramMap);
|
||||
statesData.forEach((e: any) => {
|
||||
let state: State = stateMap.get(e.state);
|
||||
if (!state) {
|
||||
cc.error('error');
|
||||
}
|
||||
this.importTransitions(e.transitions, state, stateMap, paramMap);
|
||||
});
|
||||
|
||||
this.MachineLayer.setCurStateMachine();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入cocos animation文件
|
||||
*/
|
||||
public importAnim(animData: any) {
|
||||
let x = Tool.randFloat(-this.MachineLayer.node.x - 100, -this.MachineLayer.node.x + 100);
|
||||
let y = Tool.randFloat(-this.MachineLayer.node.y - 100, -this.MachineLayer.node.y + 100);
|
||||
let unitState = this.MachineLayer.createState(cc.v2(x, y));
|
||||
let state: State = unitState.state;
|
||||
state.name = animData._name;
|
||||
state.motion = animData._name;
|
||||
state.speed = animData.speed;
|
||||
state.loop = animData.wrapMode === cc.WrapMode.Loop;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入spine json文件
|
||||
*/
|
||||
public improtSpine(spineData: any) {
|
||||
for (let name in spineData.animations) {
|
||||
let x = Tool.randFloat(-this.MachineLayer.node.x - 100, -this.MachineLayer.node.x + 100);
|
||||
let y = Tool.randFloat(-this.MachineLayer.node.y - 100, -this.MachineLayer.node.y + 100);
|
||||
let unitState = this.MachineLayer.createState(cc.v2(x, y));
|
||||
let state: State = unitState.state;
|
||||
state.name = name;
|
||||
state.motion = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入dragonbones json文件
|
||||
*/
|
||||
public importDragonBones(data: any) {
|
||||
data.armature.forEach((e) => {
|
||||
e.animation.forEach((anim) => {
|
||||
let x = Tool.randFloat(-this.MachineLayer.node.x - 100, -this.MachineLayer.node.x + 100);
|
||||
let y = Tool.randFloat(-this.MachineLayer.node.y - 100, -this.MachineLayer.node.y + 100);
|
||||
let unitState = this.MachineLayer.createState(cc.v2(x, y));
|
||||
let state: State = unitState.state;
|
||||
state.name = anim.name;
|
||||
state.motion = anim.name;
|
||||
state.loop = anim.playTimes === 0;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出工程数据
|
||||
*/
|
||||
public exportProject() {
|
||||
let main = this.MachineLayer.mainStateMachine;
|
||||
let animator = ANIMATOR_VERSION;
|
||||
let mainStateMachine = {
|
||||
layerPos: [main.layerPos.x, main.layerPos.y],
|
||||
layerScale: main.layerScale,
|
||||
anyStatePos: [main.anyStatePos.x, main.anyStatePos.y],
|
||||
subStates: [],
|
||||
subStateMachines: [],
|
||||
};
|
||||
main.subStates.forEach((e) => {
|
||||
mainStateMachine.subStates.push(e.name);
|
||||
});
|
||||
main.subStateMachines.forEach((e) => {
|
||||
mainStateMachine.subStateMachines.push(e.name);
|
||||
});
|
||||
let subStateMachines = [];
|
||||
this.exportAllSubMachine(subStateMachines, main);
|
||||
|
||||
let defaultState: string = this.MachineLayer.defaultState ? this.MachineLayer.defaultState.name : '';
|
||||
let anyState = {
|
||||
transitions: this.MachineLayer.anyState.state.getAllTransitionData()
|
||||
};
|
||||
let states = [];
|
||||
this.exportAllState(states, main);
|
||||
return {
|
||||
animator: animator,
|
||||
mainStateMachine: mainStateMachine,
|
||||
subStateMachines: subStateMachines,
|
||||
defaultState: defaultState,
|
||||
anyState: anyState,
|
||||
states: states
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出runtime数据
|
||||
*/
|
||||
public exportRuntimeData() {
|
||||
let main = this.MachineLayer.mainStateMachine;
|
||||
let defaultState: string = this.MachineLayer.defaultState ? this.MachineLayer.defaultState.name : '';
|
||||
let anyState = {
|
||||
transitions: this.MachineLayer.anyState.state.getAllTransitionData()
|
||||
};
|
||||
let states = [];
|
||||
this.exportAllState(states, main, true);
|
||||
return {
|
||||
defaultState: defaultState,
|
||||
anyState: anyState,
|
||||
states: states
|
||||
};
|
||||
}
|
||||
//#endregion
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ import UnitStateMachine from "./UnitStateMachine";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
/** 状态机视图界面边长 */
|
||||
const LEN = 9000;
|
||||
|
||||
@ccclass
|
||||
export default class MachineLayer extends cc.Component {
|
||||
@property(cc.Node) Grid: cc.Node = null;
|
||||
@ -36,11 +39,11 @@ export default class MachineLayer extends cc.Component {
|
||||
private _upUnit: UnitStateMachine = null;
|
||||
|
||||
protected onLoad() {
|
||||
this.node.setContentSize(6750, 6750);
|
||||
this.Grid.setContentSize(6750, 6750);
|
||||
this.node.setContentSize(LEN, LEN);
|
||||
this.Grid.setContentSize(LEN, LEN);
|
||||
this._mainStateMachine = new StateMachine(null);
|
||||
this._curStateMachine = this._mainStateMachine;
|
||||
this._anyState = this.createState(cc.v2(-360, 300), true);
|
||||
this._anyState = this.createState(cc.v2(-300, 300), true);
|
||||
this._curStateMachine.setAnyStatePos(this._anyState.node.position);
|
||||
|
||||
this.NavBar.refreshBar([this._mainStateMachine]);
|
||||
@ -121,7 +124,7 @@ export default class MachineLayer extends cc.Component {
|
||||
node.destroy();
|
||||
}
|
||||
|
||||
// 生成状态机、状态、连线节点
|
||||
// 生成状态、状态机节点
|
||||
let stateMap: Map<State, UnitState> = new Map();
|
||||
let machineMap: Map<StateMachine, UnitStateMachine> = new Map();
|
||||
this._upUnit && machineMap.set(stateMachine.upStateMachine, this._upUnit);
|
||||
@ -154,7 +157,7 @@ export default class MachineLayer extends cc.Component {
|
||||
}
|
||||
machineMap.set(e, unitStateMachine);
|
||||
});
|
||||
|
||||
// 生成连线节点
|
||||
let stateKeys = stateMap.keys();
|
||||
for (let i = 0; i < stateMap.size; i++) {
|
||||
let state: State = stateKeys.next().value;
|
||||
|
@ -18,6 +18,7 @@ export default class NavBar extends cc.Component {
|
||||
protected onLoad() {
|
||||
this._widget = this.getComponent(cc.Widget);
|
||||
this._contentWidget = this.Content.getComponent(cc.Widget);
|
||||
this.onEventResize();
|
||||
Events.targetOn(this);
|
||||
}
|
||||
|
||||
@ -43,8 +44,8 @@ export default class NavBar extends cc.Component {
|
||||
}
|
||||
|
||||
@preloadEvent(EventName.RESIZE)
|
||||
private onEventResize(node: cc.Node) {
|
||||
this._widget.left = Editor.Inst.ParamCtr.node.width;
|
||||
private onEventResize(node?: cc.Node) {
|
||||
this._widget.left = Editor.Inst.Parameters.node.width;
|
||||
this._widget.right = Editor.Inst.Inspector.node.width;
|
||||
this._widget.updateAlignment();
|
||||
this._contentWidget.updateAlignment();
|
||||
|
@ -128,15 +128,14 @@ export default class ConditionItem extends cc.Component implements RecycleNode {
|
||||
|
||||
private onClickParamSelect(event: cc.Event) {
|
||||
let target: cc.Node = event.target;
|
||||
let worldPos: cc.Vec2 = target.parent.convertToWorldSpaceAR(target.position.sub(cc.v2(0, 0)));
|
||||
Events.emit(EventName.SHOW_PARAM_SELECT, worldPos, 30, this);
|
||||
Events.emit(EventName.SHOW_PARAM_SELECT, target, this);
|
||||
this._hasInit && Events.emit(EventName.CONDITION_SELECT, this);
|
||||
}
|
||||
|
||||
private onClickLogicSelect(event: cc.Event) {
|
||||
let target: cc.Node = event.target;
|
||||
let worldPos: cc.Vec2 = target.parent.convertToWorldSpaceAR(target.position.sub(cc.v2(0, 0)));
|
||||
Events.emit(EventName.SHOW_LOGIC, worldPos, 30, this);
|
||||
Events.emit(EventName.SHOW_LOGIC, worldPos, target.height, this);
|
||||
this._hasInit && Events.emit(EventName.CONDITION_SELECT, this);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ import DragList from "../../common/cmpt/DragList";
|
||||
import Events, { EventName, preloadEvent } from "../../common/util/Events";
|
||||
import RecyclePool from "../../common/util/RecyclePool";
|
||||
import Res from "../../common/util/Res";
|
||||
import Tool from "../../common/util/Tool";
|
||||
import { ResUrl } from "../../constant/ResUrl";
|
||||
import Transition from "../data/Transition";
|
||||
import Editor from "../Editor";
|
||||
@ -129,6 +130,7 @@ export default class InspectorCtr extends cc.Component {
|
||||
let prefab = Res.getLoaded(ResUrl.PREFAB.TRANSITION_ITEM);
|
||||
let node: cc.Node = RecyclePool.get(TransitionItem) || cc.instantiate(prefab);
|
||||
node.width = this.TransitionList.node.width;
|
||||
Tool.updateWidget(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -141,6 +143,7 @@ export default class InspectorCtr extends cc.Component {
|
||||
let prefab = Res.getLoaded(ResUrl.PREFAB.CONDITION_ITEM);
|
||||
let node: cc.Node = RecyclePool.get(ConditionItem) || cc.instantiate(prefab);
|
||||
node.width = this.ConditionList.node.width;
|
||||
Tool.updateWidget(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -300,10 +303,7 @@ export default class InspectorCtr extends cc.Component {
|
||||
if (!(this._unit instanceof UnitState)) {
|
||||
return;
|
||||
}
|
||||
let target = event.target;
|
||||
let worldPos = target.parent.convertToWorldSpaceAR(target.position);
|
||||
worldPos.y -= target.height / 2;
|
||||
Events.emit(EventName.SHOW_MULTIPLIER, worldPos);
|
||||
Events.emit(EventName.SHOW_MULTIPLIER, event.target);
|
||||
}
|
||||
|
||||
private onClickDeleteTransition() {
|
||||
@ -338,11 +338,11 @@ export default class InspectorCtr extends cc.Component {
|
||||
if (!this._transitionItem) {
|
||||
return;
|
||||
}
|
||||
if (Editor.Inst.ParamCtr.ParamContent.childrenCount <= 0) {
|
||||
if (Editor.Inst.Parameters.ParamContent.childrenCount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
let paramItem: ParamItem = Editor.Inst.ParamCtr.ParamContent.children[0].getComponent(ParamItem);
|
||||
let paramItem: ParamItem = Editor.Inst.Parameters.ParamContent.children[0].getComponent(ParamItem);
|
||||
let data = this._transitionItem.transition.addCondition(paramItem);
|
||||
let node = this.getConditionItem();
|
||||
this.ConditionList.node.addChild(node);
|
||||
@ -463,17 +463,21 @@ export default class InspectorCtr extends cc.Component {
|
||||
if (node !== this.node) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tool.updateWidget(this.node, this.TransitionList.node, this.ConditionList.node);
|
||||
if (!this.TransitionInfo.active) {
|
||||
return;
|
||||
}
|
||||
this.TransitionList.node.children.forEach((e) => {
|
||||
e.width = this.TransitionList.node.width;
|
||||
Tool.updateWidget(e);
|
||||
});
|
||||
if (!this.ConditionInfo.active) {
|
||||
return;
|
||||
}
|
||||
this.ConditionList.node.children.forEach((e) => {
|
||||
e.width = this.ConditionList.node.width;
|
||||
Tool.updateWidget(e);
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Events, { EventName, preloadEvent } from "../../common/util/Events";
|
||||
import RecyclePool from "../../common/util/RecyclePool";
|
||||
import Res from "../../common/util/Res";
|
||||
import Tool from "../../common/util/Tool";
|
||||
import { ParamType } from "../../constant/BaseConst";
|
||||
import { ResUrl } from "../../constant/ResUrl";
|
||||
import State from "../data/State";
|
||||
@ -134,7 +135,13 @@ export default class Menu extends cc.Component {
|
||||
let num = cc.misc.clampf(this.LineToSubList.content.childrenCount, 1, 10);
|
||||
this.LineToSubList.node.height = 40 * num + 20;
|
||||
this.LineToSubList.content.parent.height = 40 * num + 20;
|
||||
this.LineToSubList.node.getChildByName('scrollBar').getComponent(cc.Widget).updateAlignment();
|
||||
if (this.LineToSubList.content.childrenCount > 10) {
|
||||
this.LineToSubList.node.getChildByName('scrollBar').active = true;
|
||||
this.LineToSubList.node.getChildByName('scrollBar').getComponent(cc.Widget).updateAlignment();
|
||||
} else {
|
||||
this.LineToSubList.node.getChildByName('scrollBar').active = false;
|
||||
}
|
||||
|
||||
// 设置坐标
|
||||
let pos = this.node.convertToNodeSpaceAR(worldPos);
|
||||
let x = pos.x;
|
||||
@ -143,9 +150,11 @@ export default class Menu extends cc.Component {
|
||||
}
|
||||
|
||||
@preloadEvent(EventName.SHOW_MULTIPLIER)
|
||||
private onEventShowMultiplierSelect(worldPos: cc.Vec2) {
|
||||
private onEventShowMultiplierSelect(target: cc.Node) {
|
||||
this.show(this.MultiplierList.node);
|
||||
|
||||
let worldPos = target.parent.convertToWorldSpaceAR(target.position);
|
||||
worldPos.y -= target.height / 2;
|
||||
this.MultiplierList.node.position = this.node.convertToNodeSpaceAR(worldPos);
|
||||
for (let i = this.MultiplierList.content.childrenCount - 1; i >= 0; i--) {
|
||||
RecyclePool.put(MultiplierItem, this.MultiplierList.content.children[i]);
|
||||
@ -153,19 +162,24 @@ export default class Menu extends cc.Component {
|
||||
let node: cc.Node = RecyclePool.get(MultiplierItem) || cc.instantiate(Res.getLoaded(ResUrl.PREFAB.MULTIPLIER_ITEM));
|
||||
this.MultiplierList.content.addChild(node);
|
||||
node.getComponent(MultiplierItem).onInit();
|
||||
Editor.Inst.ParamCtr.ParamContent.children.forEach((e) => {
|
||||
node.width = target.width;
|
||||
Editor.Inst.Parameters.ParamContent.children.forEach((e) => {
|
||||
let paramItem = e.getComponent(ParamItem);
|
||||
if (paramItem.type !== ParamType.NUMBER) {
|
||||
return;
|
||||
}
|
||||
let node: cc.Node = RecyclePool.get(MultiplierItem) || cc.instantiate(Res.getLoaded(ResUrl.PREFAB.MULTIPLIER_ITEM));
|
||||
node = RecyclePool.get(MultiplierItem) || cc.instantiate(Res.getLoaded(ResUrl.PREFAB.MULTIPLIER_ITEM));
|
||||
this.MultiplierList.content.addChild(node);
|
||||
node.getComponent(MultiplierItem).onInit(paramItem);
|
||||
node.width = target.width;
|
||||
});
|
||||
|
||||
let num = cc.misc.clampf(this.MultiplierList.content.childrenCount, 1, 10);
|
||||
this.MultiplierList.node.height = 40 * num + 20;
|
||||
this.MultiplierList.content.parent.height = 40 * num + 20;
|
||||
this.MultiplierList.node.getChildByName('scrollBar').getComponent(cc.Widget).updateAlignment();
|
||||
this.MultiplierList.node.width = target.width;
|
||||
Tool.updateWidget(this.MultiplierList.node);
|
||||
this.MultiplierList.node.getChildByName('scrollBar').active = this.MultiplierList.content.childrenCount > 10;
|
||||
}
|
||||
|
||||
@preloadEvent(EventName.SHOW_PARAM_ADD)
|
||||
@ -176,27 +190,31 @@ export default class Menu extends cc.Component {
|
||||
}
|
||||
|
||||
@preloadEvent(EventName.SHOW_PARAM_SELECT)
|
||||
private onEventShowParamSelect(worldPos: cc.Vec2, targetHeight: number, conditionItem: ConditionItem) {
|
||||
private onEventShowParamSelect(target: cc.Node, conditionItem: ConditionItem) {
|
||||
this.show(this.ParamSelect.node);
|
||||
|
||||
let worldPos: cc.Vec2 = target.parent.convertToWorldSpaceAR(target.position.sub(cc.v2(0, 0)));
|
||||
for (let i = this.ParamSelect.content.childrenCount - 1; i >= 0; i--) {
|
||||
RecyclePool.put(ParamSelectItem, this.ParamSelect.content.children[i]);
|
||||
}
|
||||
// 生成item
|
||||
Editor.Inst.ParamCtr.ParamContent.children.forEach((e) => {
|
||||
Editor.Inst.Parameters.ParamContent.children.forEach((e) => {
|
||||
let node: cc.Node = RecyclePool.get(ParamSelectItem) || cc.instantiate(Res.getLoaded(ResUrl.PREFAB.PARAM_SELECT_ITEM));
|
||||
this.ParamSelect.content.addChild(node);
|
||||
node.getComponent(ParamSelectItem).onInit(e.getComponent(ParamItem), conditionItem);
|
||||
node.width = target.width;
|
||||
});
|
||||
|
||||
let num = cc.misc.clampf(this.ParamSelect.content.childrenCount, 1, 10);
|
||||
this.ParamSelect.node.height = 40 * num + 10;
|
||||
this.ParamSelect.content.parent.height = 40 * num + 10;
|
||||
this.ParamSelect.node.getChildByName('scrollBar').getComponent(cc.Widget).updateAlignment();
|
||||
if (worldPos.y - targetHeight / 2 - this.ParamSelect.node.height > 0) {
|
||||
this.ParamSelect.node.position = this.node.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y - targetHeight / 2));
|
||||
this.ParamSelect.node.width = target.width;
|
||||
Tool.updateWidget(this.ParamSelect.node);
|
||||
this.ParamSelect.node.getChildByName('scrollBar').active = this.ParamSelect.content.childrenCount > 10;
|
||||
if (worldPos.y - target.height / 2 - this.ParamSelect.node.height > 0) {
|
||||
this.ParamSelect.node.position = this.node.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y - target.height / 2));
|
||||
} else {
|
||||
this.ParamSelect.node.position = this.node.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y + targetHeight / 2 + this.ParamSelect.node.height));
|
||||
this.ParamSelect.node.position = this.node.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y + target.height / 2 + this.ParamSelect.node.height));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Events, { EventName, preloadEvent } from "../../common/util/Events";
|
||||
import RecyclePool from "../../common/util/RecyclePool";
|
||||
import Res from "../../common/util/Res";
|
||||
import Tool from "../../common/util/Tool";
|
||||
import { ParameterData } from "../../constant/BaseConst";
|
||||
import { ResUrl } from "../../constant/ResUrl";
|
||||
import ParamItem from "./ParamItem";
|
||||
@ -73,6 +74,7 @@ export default class ParamCtr extends cc.Component {
|
||||
let prefab = Res.getLoaded(ResUrl.PREFAB.PARAM_ITEM);
|
||||
let node: cc.Node = RecyclePool.get(ParamItem) || cc.instantiate(prefab);
|
||||
node.width = this.ParamContent.width;
|
||||
Tool.updateWidget(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -146,8 +148,11 @@ export default class ParamCtr extends cc.Component {
|
||||
if (node !== this.node) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tool.updateWidget(this.node, this.ParamContent);
|
||||
this.ParamContent.children.forEach((e) => {
|
||||
e.width = this.ParamContent.width;
|
||||
Tool.updateWidget(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ export default class ParamItem extends cc.Component implements RecycleNode {
|
||||
return;
|
||||
}
|
||||
|
||||
this.NameEdit.string = Editor.Inst.ParamCtr.getParamName(this, this.NameEdit.string);
|
||||
this.NameEdit.string = Editor.Inst.Parameters.getParamName(this, this.NameEdit.string);
|
||||
this.paramName = this.NameEdit.string;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class Main extends cc.Component {
|
||||
private _editorNode: cc.Node = null;
|
||||
private _editor: Editor = null;
|
||||
|
||||
protected onLoad() {
|
||||
cc.debug.setDisplayStats(false);
|
||||
@ -22,17 +22,16 @@ export default class Main extends cc.Component {
|
||||
this.dragOn();
|
||||
}
|
||||
|
||||
private resetEditor(): Editor {
|
||||
if (this._editorNode) {
|
||||
this._editorNode.getComponent(Editor).Fsm.MachineLayer.clear();
|
||||
this._editorNode.removeFromParent();
|
||||
this._editorNode.destroy();
|
||||
private resetEditor() {
|
||||
if (this._editor) {
|
||||
this._editor.Fsm.MachineLayer.clear();
|
||||
this._editor.node.removeFromParent();
|
||||
this._editor.node.destroy();
|
||||
}
|
||||
this._editorNode = cc.instantiate(Res.getLoaded(ResUrl.PREFAB.EDITOR));
|
||||
this.node.addChild(this._editorNode);
|
||||
let editor = this._editorNode.getComponent(Editor);
|
||||
Editor.Inst = editor;
|
||||
return editor;
|
||||
let node = cc.instantiate(Res.getLoaded(ResUrl.PREFAB.EDITOR));
|
||||
this._editor = node.getComponent(Editor);
|
||||
Editor.Inst = this._editor;
|
||||
this.node.addChild(node);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,25 +62,58 @@ export default class Main extends cc.Component {
|
||||
e.stopPropagation();
|
||||
// 处理拖拽文件的逻辑
|
||||
let files = e.dataTransfer.files;
|
||||
let reg = /\.json$/;
|
||||
if (!reg.test(files[0].name)) {
|
||||
return;
|
||||
}
|
||||
this.readProject(files[0]);
|
||||
this.readFiles(files);
|
||||
}, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取工程文件
|
||||
* 文件读取
|
||||
*/
|
||||
private readProject(file: File) {
|
||||
private readFiles(files: FileList) {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file: File = files[i];
|
||||
if (/\.json$/.test(file.name)) {
|
||||
this.readJson(file);
|
||||
} else if (/\.anim$/.test(file.name)) {
|
||||
this.readAnim(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取.json文件
|
||||
*/
|
||||
private readJson(file: File) {
|
||||
let fileReader = new FileReader();
|
||||
fileReader.readAsText(file);
|
||||
fileReader.onload = () => {
|
||||
cc.log(fileReader.result);
|
||||
let data: any = JSON.parse(fileReader.result as string);
|
||||
if (data.animator) {
|
||||
// 读取状态机工程文件
|
||||
this.resetEditor();
|
||||
this._editor.Parameters.import(data.parameters);
|
||||
this._editor.Fsm.importProject(data);
|
||||
} else if (data.skeleton && data.animations) {
|
||||
// 读取spine文件
|
||||
this._editor.Fsm.improtSpine(data);
|
||||
} else if (data.armature) {
|
||||
// 读取龙骨文件
|
||||
this._editor.Fsm.importDragonBones(data);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let editor = this.resetEditor();
|
||||
editor.importProject(JSON.parse(fileReader.result as string));
|
||||
/**
|
||||
* 读取cocos .anim文件
|
||||
*/
|
||||
private readAnim(file: File) {
|
||||
let fileReader = new FileReader();
|
||||
fileReader.readAsText(file);
|
||||
fileReader.onload = () => {
|
||||
cc.log(fileReader.result);
|
||||
let data: any = JSON.parse(fileReader.result as string);
|
||||
this._editor.Fsm.importAnim(data);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user