浏览代码

update raycastable scene

/add_hero_sample
Xingwei Zhu 3 年前
当前提交
84f9b106
共有 10 个文件被更改,包括 2258 次插入183 次删除
  1. 752
      AwesomeUIWidgets/Assets/Scenes/RaycastablePickerRoom.unity
  2. 112
      AwesomeUIWidgets/Assets/Scripts/RaycastableScene/GameObjectManager.cs
  3. 15
      AwesomeUIWidgets/Assets/Scripts/RaycastableScene/ItemPickerMainUIPanel.cs
  4. 4
      AwesomeUIWidgets/Assets/Scripts/RaycastableScene/RaycastableSceneConfig.cs
  5. 20
      AwesomeUIWidgets/Assets/Scripts/RaycastableScene/RightUIPanel.cs
  6. 80
      AwesomeUIWidgets/Assets/Scripts/RaycastableScene/SceneBoard.cs
  7. 1001
      AwesomeUIWidgets/Assets/Scripts/RaycastableScene/custom_slider.cs
  8. 3
      AwesomeUIWidgets/Assets/Scripts/RaycastableScene/custom_slider.cs.meta
  9. 451
      AwesomeUIWidgets/Assets/Scripts/RaycastableScene/custom_switch.cs
  10. 3
      AwesomeUIWidgets/Assets/Scripts/RaycastableScene/custom_switch.cs.meta

752
AwesomeUIWidgets/Assets/Scenes/RaycastablePickerRoom.unity


m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 248180364}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &262194660 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1543346588463464, guid: 4242dcc21ff0bc1479e2bde7b663c464,
type: 3}
m_PrefabInstance: {fileID: 1819584078}
m_PrefabAsset: {fileID: 0}
--- !u!114 &262194661
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 262194660}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &262194662
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 262194660}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.2851294, y: 0.7070279, z: 0.32082397}
m_Center: {x: -0.048262265, y: 0.35129797, z: 0}
--- !u!1001 &280757503
PrefabInstance:
m_ObjectHideFlags: 0

m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &394982910 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1832056105147992, guid: 542eac6dcaa12ba4aae6437db06b46ee,
type: 3}
m_PrefabInstance: {fileID: 151948445}
m_PrefabAsset: {fileID: 0}
--- !u!114 &394982911
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 394982910}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &394982912
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 394982910}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.5036242, y: 0.7211165, z: 0.37445003}
m_Center: {x: 0.03918201, y: 0.35141626, z: 0}
--- !u!1 &410074745
GameObject:
m_ObjectHideFlags: 0

objectReference: {fileID: 0}
- target: {fileID: 4766148506136828, guid: 13ab75576c9285f498790e76c1a87c90, type: 3}
propertyPath: m_LocalPosition.z
value: -9.29
value: -10.44
objectReference: {fileID: 0}
- target: {fileID: 4766148506136828, guid: 13ab75576c9285f498790e76c1a87c90, type: 3}
propertyPath: m_LocalRotation.w

objectReference: {fileID: 2100000, guid: 397ff9c94add56c4eac4cdddc65d52fa, type: 2}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 13ab75576c9285f498790e76c1a87c90, type: 3}
--- !u!1 &474205085 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1503180181874650, guid: b3b64fffd0a01784bba52106fbea62f1,
type: 3}
m_PrefabInstance: {fileID: 381059644}
m_PrefabAsset: {fileID: 0}
--- !u!114 &474205086
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 474205085}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &474205087
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 474205085}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.7360075, y: 0.79006153, z: 1.396293}
m_Center: {x: 0.011192232, y: 0.39026526, z: 0}
--- !u!1001 &498399276
PrefabInstance:
m_ObjectHideFlags: 0

objectReference: {fileID: 2100000, guid: fb881332404674f4fae9c888043924e1, type: 2}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5d891f94d48551e439ac5b24a9ec00cc, type: 3}
--- !u!1 &532006322 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1180148154098208, guid: e852a6b66b86e9a4ea1fdeb1ccc625bc,
type: 3}
m_PrefabInstance: {fileID: 280757503}
m_PrefabAsset: {fileID: 0}
--- !u!114 &532006323
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 532006322}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &532006324
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 532006322}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.4967077, y: 0.79354614, z: 0.70035446}
m_Center: {x: -0.048712492, y: 0.350907, z: -0.000000003558755}
--- !u!4 &536034910 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4261933636434198, guid: 20b83b6c7039f5d47beac9ffafe09d6e,

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 665285921}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &702562097 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1940725992751248, guid: 36dbe61bd75ee1247b4f749534847ff0,
type: 3}
m_PrefabInstance: {fileID: 849945056}
m_PrefabAsset: {fileID: 0}
--- !u!114 &702562098
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 702562097}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &702562099
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 702562097}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.56169796, y: 0.7103975, z: 0.308852}
m_Center: {x: 0.008832499, y: 0.34828526, z: 0}
--- !u!1 &775581731
GameObject:
m_ObjectHideFlags: 0

m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 856172078}
m_Texture: {fileID: 788581131}
m_UVRect:
serializedVersion: 2
x: 0

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 775581731}
m_CullTransparentMesh: 0
--- !u!28 &788581131
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
--- !u!1001 &849945056
PrefabInstance:
m_ObjectHideFlags: 0

objectReference: {fileID: 0}
- target: {fileID: 4098154856099424, guid: 36dbe61bd75ee1247b4f749534847ff0, type: 3}
propertyPath: m_LocalPosition.y
value: 6.27
value: 6.339
value: -12.75
value: -13.193
objectReference: {fileID: 0}
- target: {fileID: 4098154856099424, guid: 36dbe61bd75ee1247b4f749534847ff0, type: 3}
propertyPath: m_LocalRotation.w

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 23210264580106770, guid: 36dbe61bd75ee1247b4f749534847ff0,
type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 59e4faf24927edf4a82f463ad16f1c37, type: 2}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 36dbe61bd75ee1247b4f749534847ff0, type: 3}
--- !u!1001 &854782982

objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 7f108f287f4d0fb40b30667322ecde51, type: 3}
--- !u!28 &856172078
Texture2D:
--- !u!1001 &890496306
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1675308188217246, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_Name
value: Rat
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_RootOrder
value: 17
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_LocalPosition.x
value: -9.07
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_LocalPosition.z
value: -6.61
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4531104235746212, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 23840011653650778, guid: 3cc9be1e4de713c4192e87916b6bab03,
type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 59e4faf24927edf4a82f463ad16f1c37, type: 2}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3cc9be1e4de713c4192e87916b6bab03, type: 3}
--- !u!1 &890496307 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1675308188217246, guid: 3cc9be1e4de713c4192e87916b6bab03,
type: 3}
m_PrefabInstance: {fileID: 890496306}
m_PrefabAsset: {fileID: 0}
--- !u!114 &890496308
MonoBehaviour:
m_GameObject: {fileID: 890496307}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_EditorClassIdentifier:
--- !u!65 &890496309
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 890496307}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
m_Size: {x: 1.381468, y: 0.747867, z: 0.289243}
m_Center: {x: -0.17627802, y: 0.37897152, z: 0}
--- !u!1 &943226306
GameObject:
m_ObjectHideFlags: 0

serializedVersion: 2
m_Size: {x: 0.99999994, y: 0.99999994, z: 6.123233e-17}
m_Center: {x: 4.5815796e-11, y: 0, z: 0}
--- !u!1001 &959982810
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1920191581749620, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_Name
value: Snake
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_RootOrder
value: 19
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_LocalPosition.x
value: -6.89
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_LocalPosition.y
value: 4.52
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_LocalPosition.z
value: -15.58
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_LocalRotation.x
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -90
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4225525764850970, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 23466581665903300, guid: a14fff62ccb8dfb4cb30aa2440d7e680,
type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 507ec159dbf1634489af3c88c554dc4e, type: 2}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a14fff62ccb8dfb4cb30aa2440d7e680, type: 3}
--- !u!1 &959982811 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1920191581749620, guid: a14fff62ccb8dfb4cb30aa2440d7e680,
type: 3}
m_PrefabInstance: {fileID: 959982810}
m_PrefabAsset: {fileID: 0}
--- !u!114 &959982812
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 959982811}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &959982813
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 959982811}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.9066505, y: 0.4719386, z: 1.0553308}
m_Center: {x: -0.08003321, y: 0.23310831, z: 0.019691234}
--- !u!1 &1023710518
GameObject:
m_ObjectHideFlags: 0

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1245375184}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1279140726 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1182029683073452, guid: 5d891f94d48551e439ac5b24a9ec00cc,
type: 3}
m_PrefabInstance: {fileID: 498399276}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1279140727
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1279140726}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &1279140728
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1279140726}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.1383594, y: 0.88803643, z: 0.27080697}
m_Center: {x: -0.008784263, y: 0.43313923, z: 0.0009544938}
--- !u!1001 &1280975685
PrefabInstance:
m_ObjectHideFlags: 0

m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 45, y: 72.73701, z: 0}
--- !u!1001 &1351106784
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1736732376848332, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_Name
value: Tiger
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_RootOrder
value: 20
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalScale.x
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalScale.y
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalScale.z
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalPosition.x
value: -7.04
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalPosition.z
value: -11.49
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalRotation.w
value: 0.28123635
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalRotation.x
value: 0.041855432
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalRotation.y
value: -0.95864666
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalRotation.z
value: -0.012279049
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: -147.3
objectReference: {fileID: 0}
- target: {fileID: 4941743527270764, guid: fb573fe406c53c740acf51407165ee68, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: -5
objectReference: {fileID: 0}
- target: {fileID: 23573720633088632, guid: fb573fe406c53c740acf51407165ee68,
type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: d8c68e9822ac2fa47ad88fb55d73ca20, type: 2}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: fb573fe406c53c740acf51407165ee68, type: 3}
--- !u!1 &1351106785 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1736732376848332, guid: fb573fe406c53c740acf51407165ee68,
type: 3}
m_PrefabInstance: {fileID: 1351106784}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1351106786
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1351106785}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &1351106787
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1351106785}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.205779, y: 0.70363057, z: 0.26908302}
m_Center: {x: -0.10976498, y: 0.3401103, z: 0.0003069999}
--- !u!1 &1454060144
GameObject:
m_ObjectHideFlags: 0

objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 20b83b6c7039f5d47beac9ffafe09d6e, type: 3}
--- !u!1001 &1604616460
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1965910811585682, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_Name
value: Rooster
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_RootOrder
value: 18
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_LocalPosition.x
value: -13.74
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_LocalPosition.y
value: 6.3
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_LocalPosition.z
value: -13.17
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_LocalRotation.w
value: 0.99251425
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_LocalRotation.y
value: -0.122129105
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: -14.03
objectReference: {fileID: 0}
- target: {fileID: 4555923442477812, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 23848886738545110, guid: 96bace41c6a85b6479d537902bdcd0e8,
type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: af53e3a7405b3a141a93bf007fb281dc, type: 2}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 96bace41c6a85b6479d537902bdcd0e8, type: 3}
--- !u!1 &1604616461 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1965910811585682, guid: 96bace41c6a85b6479d537902bdcd0e8,
type: 3}
m_PrefabInstance: {fileID: 1604616460}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1604616462
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1604616461}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &1604616463
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1604616461}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.68879247, y: 0.78412855, z: 0.293323}
m_Center: {x: -0.07076375, y: 0.38407075, z: 0}
--- !u!1 &1617165399
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: fa69e2d9892346bfac8ad4dfc88af371, type: 3}
m_Name:
m_EditorClassIdentifier:
cube: {fileID: 8961943036043786051, guid: 90c7dde08862b9945bab6d5c1ff8473c, type: 3}
ball: {fileID: 3259445113941571833, guid: 9152c5b499e52544eafe077bc7048fbf, type: 3}
cylinder: {fileID: 2581742516055541185, guid: 26a44dfb8d31fa74b89ff502c058df6b,
type: 3}
--- !u!1 &1681292596 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1010573664472510, guid: 821bdb56c4110c841816df2632335cc6,
type: 3}
m_PrefabInstance: {fileID: 1280975685}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1681292597
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1681292596}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &1681292598
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1681292596}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.24878, y: 0.73239046, z: 0.243264}
m_Center: {x: 0.013533503, y: 0.36601225, z: 0}
--- !u!1001 &1688741613
PrefabInstance:
m_ObjectHideFlags: 0

objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 6d6892a877c0a664cb5a53eb2dd13c88, type: 3}
--- !u!1 &1768023169 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1598459088720226, guid: 13ab75576c9285f498790e76c1a87c90,
type: 3}
m_PrefabInstance: {fileID: 449250158}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1768023170
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1768023169}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &1768023171
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1768023169}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.0974841, y: 0.7168825, z: 0.21920814}
m_Center: {x: -0.11870331, y: 0.35689875, z: 0.0033790043}
--- !u!1001 &1819584078
PrefabInstance:
m_ObjectHideFlags: 0

serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: -0.000000059604645, z: -0.00000047683716}
--- !u!1 &1991381104 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1749815345293910, guid: 4e58ae21638664c40b41bfceac2427a0,
type: 3}
m_PrefabInstance: {fileID: 601959713}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1991381105
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1991381104}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70433a8c34b64295acbc20adc0a670f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &1991381106
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1991381104}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.8193925, y: 0.70157593, z: 0.32303604}
m_Center: {x: 0.051454246, y: 0.35018995, z: -0.041598503}
--- !u!1 &2023127886
GameObject:
m_ObjectHideFlags: 0

112
AwesomeUIWidgets/Assets/Scripts/RaycastableScene/GameObjectManager.cs


using System.Collections.Generic;
using System.Linq;
public class ObjectItem
public class ItemInfo
public string itemObjName;
public string itemDesc;
public string name;
public Vector3 cameraPosition;
public ItemInfo(string name, string desc, Vector3 cameraPosition)
{
itemObjName = name;
itemDesc = desc;
this.cameraPosition = cameraPosition;
}
public GameObject cube;
public GameObject ball;
public GameObject cylinder;
public static ItemInfo[] itemInfos = new[]
{
new ItemInfo("Crane", "1", new Vector3(-5.69f, 2.38f, -1.36f)),
new ItemInfo("Dog", "2", new Vector3(-2.44f, 1.31f, -2.96f)),
new ItemInfo("Dragon", "3", new Vector3(-0.38f, 4.21f, -2.74f)),
new ItemInfo("Goat", "4", new Vector3(-0.1f, 1.55f, -4.42f)),
new ItemInfo("Horse", "5", new Vector3(-4.21f, 1.55f, -4.96f)),
new ItemInfo("Monkey", "6", new Vector3(2.88f, 3.66f, -7.28f)),
new ItemInfo("Ox", "7", new Vector3(1.08f, 1.23f, -1.86f)),
new ItemInfo("Pig", "8", new Vector3(-4.2f, 0.95f, -2.49f)),
new ItemInfo("Rabbit", "9", new Vector3(0.53f, 6.7f, -10.19f)),
new ItemInfo("Rat", "10", new Vector3(-8.8f, 1.19f, -1.99f)),
new ItemInfo("Rooster", "11", new Vector3(-13.71f, 6.8f, -9.48f)),
new ItemInfo("Snake", "12", new Vector3(-6.88f, 4.9f, -9.6f)),
new ItemInfo("Tiger", "13", new Vector3(-6.85f, 1.51f, -6.41f))
};
public static List<PickListItem> listItems => itemInfos.Select(x => new PickListItem(x.itemObjName, true, x.itemObjName)).ToList();
public static Dictionary<string, ObjectItem> objects = new Dictionary<string, ObjectItem>();
public static Dictionary<string, ItemInfo> objects = new Dictionary<string, ItemInfo>();
public static Vector3? cameraPosition;

// public static List<GameObject> closeObjects = new List<GameObject>();
public Vector3 NewPosition()
{
int count = objects.Count;
int sq = (int) Mathf.Sqrt(count);
int remain = count - sq * sq;
int r = 0;
int c = 0;
if (remain <= sq)
{
r = sq;
c = remain;
}
else
{
r = 2 * sq - remain;
c = sq;
}
var s = RaycastableSceneConfig.scaterScale;
return center.position + new Vector3(r * s, c * s, 0);
}
public void CreateGameObject(GameObject obj, int count, string name)
{
int sq = (int)Mathf.Sqrt(count);
if (obj)
{
for (int i = 0; i <count; i++)
{
int r = i % sq;
int c = i / sq;
int s = 1;
var position = NewPosition();
var newObj = Instantiate(obj, position, Quaternion.identity);
newObj.name = $"{name}{i + 1}";
objects.Add(newObj.name, new ObjectItem()
{
obj = newObj,
name = newObj.name,
position = newObj.transform.position,
active = true
});
}
}
}
objects.Clear();
CreateGameObject(cube, RaycastableSceneConfig.cubeCount, RaycastableSceneConfig.cubeName);
CreateGameObject(ball, RaycastableSceneConfig.ballCount, RaycastableSceneConfig.ballName);
CreateGameObject(cylinder, RaycastableSceneConfig.cylinderCount, RaycastableSceneConfig.cylinderName);
foreach (var item in itemInfos)
{
var newInfo = new ItemInfo(item.itemObjName, item.itemDesc, item.cameraPosition);
newInfo.active = true;
newInfo.obj = GameObject.Find(item.itemObjName);
newInfo.position = newInfo.obj.transform.position;
objects.Add(item.itemObjName, newInfo);
}
}

}
}
void OnDisable()
{
foreach (var obj in objects)
{
Destroy(obj.Value.obj);
}
}
cameraPosition = new Vector3(obj.position.x, obj.position.y, cameraInstance.transform.position.z);
cameraPosition = obj.cameraPosition;
}
}

15
AwesomeUIWidgets/Assets/Scripts/RaycastableScene/ItemPickerMainUIPanel.cs


private Widget buildRight()
{
return new RaycastableContainer(child: new Container(width: 100f, color: Colors.grey.withAlpha(125)));
return new RaycastableContainer(child: new Container(width: 100f, color: Colors.grey.withAlpha(125), child: new RightUIPanel()));
itemNames: new List<PickListItem>
{
new PickListItem("cube1"),
new PickListItem("cube2"),
new PickListItem("cube3"),
new PickListItem("cube4"),
new PickListItem("ball1"),
new PickListItem("ball2"),
new PickListItem("ball3"),
new PickListItem("cylinder1"),
new PickListItem("cylinder2")
},
itemNames: GameObjectManager.listItems,
itemCheckCallback: (index, active) =>
{
//TODO: callback when item is activated/inactivated

4
AwesomeUIWidgets/Assets/Scripts/RaycastableScene/RaycastableSceneConfig.cs


{
public static class RaycastableSceneConfig
{
public const int fontSize = 20;
public const int fontSize = 10;
public static readonly TextStyle fontStyle = new TextStyle(
color: Colors.white,
fontSize: fontSize

public const int scaterScale = 2;
public const float delta = 0.2f;
public const float cameraSpeed = 4;
public const float cameraSpeed = 8;
public const float scaleSceneBoard = 0.5f;
public static readonly Vector3 far = new Vector3(1000, 0, 0);
}

20
AwesomeUIWidgets/Assets/Scripts/RaycastableScene/RightUIPanel.cs


using System.Collections.Generic;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
public class RightUIPanel
public class RightUIPanel : StatelessWidget
public override Widget build(BuildContext context)
{
return new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children : new List<Widget>{
new Text("HOW TO PLAY: \n " +
"(1) Change lights using the switcher and slider at the top;\n " +
"(3) Zoom/Hide/Show a Origami using the list on the left;\n " +
"(4) Click on the Origami and drag to rotate it;", style: new TextStyle(color: Color.white, fontSize: 8f))}
);
}
}
}

80
AwesomeUIWidgets/Assets/Scripts/RaycastableScene/SceneBoard.cs


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;
using Canvas = Unity.UIWidgets.ui.Canvas;
using UnityEngine;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Transform = Unity.UIWidgets.widgets.Transform;
namespace UIWidgetsSample.RaycastableScene
{

color: RaycastableSceneConfig.mainColor,
child:
new Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisAlignment: MainAxisAlignment.start,
children: new List<Widget>()
{
new Padding(padding: EdgeInsets.only(left:10f)),

fontStyle: FontStyle.italic
)),
new Padding(padding: EdgeInsets.only(left: 50f)),
child: Transform.scale(
alignment: Alignment.center,
scale: RaycastableSceneConfig.scaleSceneBoard,
child: new Container(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: new List<Widget>
{
new ActionBox(

LightController.SwitchLight(value);
}),
new Padding(padding: EdgeInsets.only(left: 30f)),
new Divider(color: Colors.black),
new Padding(padding: EdgeInsets.only(right: 30f)),
new LightSlider()
new LightSlider(),
})
)),
}

{
private float _currentSliderValue = 0;
private Color[] colors = new[]
{
Colors.white,
Colors.red,
Colors.green,
Colors.blue,
Colors.yellow,
Colors.pink,
Colors.brown,
Colors.purple,
Colors.orange,
Colors.black
};
var color = HSVColor.fromAHSV(1, _currentSliderValue * 360, 1, 1).toColor();
var indexValue = _currentSliderValue * 10;
var index = (int) Mathf.Clamp(indexValue, 0, 9);
var color = colors[index];//HSVColor.fromAHSV(1, _currentSliderValue * 360, 1, 1).toColor();
new Container(width: 20, height: 20, color: color),
new Padding(padding: EdgeInsets.only(left: 7f)),
min: 0,
max: 1,
activeColor: color,
divisions: 10,
onChanged: (value) =>
{
setState(() =>

}
);
}
}
class _SliderIndicatorPainter : CustomPainter {
readonly float position;
_SliderIndicatorPainter(float position)
{
this.position = position;
}
public void paint(Canvas canvas, Size size) {
canvas.drawCircle(
new Offset(position, size.height / 2), 12, new Paint(){color = Colors.black});
}
public bool shouldRepaint(CustomPainter oldDelegate)
{
return true;
}
public bool? hitTest(Offset position)
{
throw new NotImplementedException();
}
public void addListener(VoidCallback listener)
{
throw new NotImplementedException();
}
public void removeListener(VoidCallback listener)
{
throw new NotImplementedException();
}
}

1001
AwesomeUIWidgets/Assets/Scripts/RaycastableScene/custom_slider.cs
文件差异内容过多而无法显示
查看文件

3
AwesomeUIWidgets/Assets/Scripts/RaycastableScene/custom_slider.cs.meta


fileFormatVersion: 2
guid: 190fd3e2eacd49828505086cb3cd9399
timeCreated: 1627612118

451
AwesomeUIWidgets/Assets/Scripts/RaycastableScene/custom_switch.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace UIWidgetsSample.RaycastableScene {
class CupertinoSwitchUtils {
public const float _kTrackWidth = 25.5f;
public const float _kTrackHeight = 15.5f;
public const float _kTrackRadius = _kTrackHeight / 2.0f;
public const float _kTrackInnerStart = _kTrackHeight / 2.0f;
public const float _kTrackInnerEnd = _kTrackWidth - _kTrackInnerStart;
public const float _kTrackInnerLength = _kTrackInnerEnd - _kTrackInnerStart;
public const float _kSwitchWidth = 29.5f;
public const float _kSwitchHeight = 19.5f;
public const float _kExtension = 3.5f;
public const float _kRadius = 7f;
public const float _kCupertinoSwitchDisabledOpacity = 0.5f;
public static readonly Color _kTrackColor = new Color(0xFFE5E5EA);
public static readonly TimeSpan _kReactionDuration = TimeSpan.FromMilliseconds(300);
public static readonly TimeSpan _kToggleDuration = TimeSpan.FromMilliseconds(200);
}
public class CupertinoSwitch : StatefulWidget {
public CupertinoSwitch(
bool value,
ValueChanged<bool> onChanged,
Key key = null,
Color activeColor = null,
Color trackColor = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
) : base(key: key) {
this.value = value;
this.onChanged = onChanged;
this.activeColor = activeColor;
this.trackColor = trackColor;
this.dragStartBehavior = dragStartBehavior;
}
public readonly bool value;
public readonly ValueChanged<bool> onChanged;
public readonly Color activeColor;
public readonly Color trackColor;
public readonly DragStartBehavior dragStartBehavior;
public override State createState() {
return new _CupertinoSwitchState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagProperty("value", value: value, ifTrue: "on", ifFalse: "off", showName: true));
properties.add(new ObjectFlagProperty<ValueChanged<bool>>("onChanged", onChanged, ifNull: "disabled"));
}
}
class _CupertinoSwitchState : TickerProviderStateMixin<CupertinoSwitch> {
public TapGestureRecognizer _tap;
public HorizontalDragGestureRecognizer _drag;
AnimationController _positionController;
public CurvedAnimation position;
AnimationController _reactionController;
public Animation<float> _reaction;
bool isInteractive {
get {
return widget.onChanged != null;
}
}
bool needsPositionAnimation = false;
public override void initState() {
base.initState();
_tap = new TapGestureRecognizer();
_tap.onTapDown = _handleTapDown;
_tap.onTapUp = _handleTapUp;
_tap.onTap = _handleTap;
_tap.onTapCancel = _handleTapCancel;
_drag = new HorizontalDragGestureRecognizer();
_drag.onStart = _handleDragStart;
_drag.onUpdate = _handleDragUpdate;
_drag.onEnd = _handleDragEnd;
_drag.dragStartBehavior = widget.dragStartBehavior;
_positionController = new AnimationController(
duration: CupertinoSwitchUtils._kToggleDuration,
value: widget.value ? 1.0f : 0.0f,
vsync: this
);
position = new CurvedAnimation(
parent: _positionController,
curve: Curves.linear
);
_reactionController = new AnimationController(
duration: CupertinoSwitchUtils._kReactionDuration,
vsync: this
);
_reaction = new CurvedAnimation(
parent: _reactionController,
curve: Curves.ease
);
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
oldWidget = (CupertinoSwitch) oldWidget;
base.didUpdateWidget(oldWidget);
_drag.dragStartBehavior = widget.dragStartBehavior;
if (needsPositionAnimation || ((CupertinoSwitch) oldWidget).value != widget.value)
_resumePositionAnimation(isLinear: needsPositionAnimation);
}
void _resumePositionAnimation( bool isLinear = true ) {
needsPositionAnimation = false;
position.curve = isLinear ? null : Curves.ease;
position.reverseCurve = isLinear ? null : Curves.ease.flipped;
if (widget.value)
_positionController.forward();
else
_positionController.reverse();
}
void _handleTapDown(TapDownDetails details) {
if (isInteractive)
needsPositionAnimation = false;
_reactionController.forward();
}
void _handleTap() {
if (isInteractive) {
widget.onChanged(!widget.value);
}
}
void _handleTapUp(TapUpDetails details) {
if (isInteractive) {
needsPositionAnimation = false;
_reactionController.reverse();
}
}
void _handleTapCancel() {
if (isInteractive)
_reactionController.reverse();
}
void _handleDragStart(DragStartDetails details) {
if (isInteractive) {
needsPositionAnimation = false;
_reactionController.forward();
}
}
void _handleDragUpdate(DragUpdateDetails details) {
if (isInteractive) {
position.curve = null;
position.reverseCurve = null;
float? delta = details.primaryDelta / CupertinoSwitchUtils._kTrackInnerLength;
switch (Directionality.of(context)) {
case TextDirection.rtl:
_positionController.setValue( _positionController.value - delta ?? 0.0f);
break;
case TextDirection.ltr:
_positionController.setValue( _positionController.value + delta ?? 0.0f);
break;
}
}
}
void _handleDragEnd(DragEndDetails details) {
setState(()=> { needsPositionAnimation = true; });
if (position.value >= 0.5 != widget.value)
widget.onChanged(!widget.value);
_reactionController.reverse();
}
public override Widget build(BuildContext context) {
if (needsPositionAnimation)
_resumePositionAnimation();
return new Opacity(
opacity: widget.onChanged == null ? CupertinoSwitchUtils._kCupertinoSwitchDisabledOpacity : 1.0f,
child: new _CupertinoSwitchRenderObjectWidget(
value: widget.value,
activeColor: CupertinoDynamicColor.resolve(
widget.activeColor ?? CupertinoColors.systemGreen,
context
),
trackColor: CupertinoDynamicColor.resolve(widget.trackColor ?? CupertinoColors.secondarySystemFill, context),
onChanged: widget.onChanged,
textDirection: Directionality.of(context),
state: this
)
);
}
public override void dispose() {
_tap.dispose();
_drag.dispose();
_positionController.dispose();
_reactionController.dispose();
base.dispose();
}
}
class _CupertinoSwitchRenderObjectWidget : LeafRenderObjectWidget {
public _CupertinoSwitchRenderObjectWidget(
Key key = null,
bool value = false,
Color activeColor = null,
Color trackColor = null,
ValueChanged<bool> onChanged = null,
TextDirection? textDirection = null,
_CupertinoSwitchState state = null
) : base(key: key) {
this.value = value;
this.activeColor = activeColor;
this.trackColor = trackColor;
this.onChanged = onChanged;
this.state = state;
this.textDirection = textDirection;
}
public readonly bool value;
public readonly Color activeColor;
public readonly Color trackColor;
public readonly ValueChanged<bool> onChanged;
public readonly _CupertinoSwitchState state;
public readonly TextDirection? textDirection;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderCupertinoSwitch(
value: value,
activeColor: activeColor,
trackColor: trackColor,
onChanged: onChanged,
textDirection: textDirection,
state: state
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
var _renderObject = renderObject as _RenderCupertinoSwitch;
_renderObject.value = value;
_renderObject.activeColor = activeColor;
_renderObject.trackColor = trackColor;
_renderObject.onChanged = onChanged;
_renderObject.textDirection = textDirection;
}
}
class _RenderCupertinoSwitch : RenderConstrainedBox {
public _RenderCupertinoSwitch(
bool value,
Color activeColor,
Color trackColor = null,
TextDirection? textDirection = null,
ValueChanged<bool> onChanged = null,
_CupertinoSwitchState state = null
) : base(additionalConstraints: BoxConstraints.tightFor(
width: CupertinoSwitchUtils._kSwitchWidth,
height: CupertinoSwitchUtils._kSwitchHeight)
) {
D.assert(state != null);
_value = value;
_activeColor = activeColor;
_trackColor = trackColor;
_onChanged = onChanged;
_textDirection = textDirection;
_state = state;
state.position.addListener(markNeedsPaint);
state._reaction.addListener(markNeedsPaint);
}
AnimationController _positionController;
CurvedAnimation _position;
AnimationController _reactionController;
Animation<float> _reaction;
public readonly _CupertinoSwitchState _state;
public bool value {
get { return _value; }
set {
D.assert(value != null);
if (value == _value)
return;
_value = value;
//markNeedsSemanticsUpdate();
}
}
bool _value;
public Color activeColor {
get { return _activeColor; }
set {
D.assert(value != null);
if (value == _activeColor) {
return;
}
_activeColor = value;
markNeedsPaint();
}
}
Color _activeColor;
public Color trackColor {
get { return _trackColor; }
set {
D.assert(value != null);
if (value == _trackColor)
return;
_trackColor = value;
markNeedsPaint();
}
}
Color _trackColor;
public ValueChanged<bool> onChanged {
get { return _onChanged; }
set {
if (value == _onChanged) {
return;
}
bool wasInteractive = isInteractive;
_onChanged = value;
if (wasInteractive != isInteractive) {
markNeedsPaint();
}
}
}
ValueChanged<bool> _onChanged;
public TextDirection? textDirection {
get { return _textDirection; }
set {
if (_textDirection == value) {
return;
}
_textDirection = value;
markNeedsPaint();
}
}
TextDirection? _textDirection;
public bool isInteractive {
get { return onChanged != null; }
}
protected override bool hitTestSelf(Offset position) {
return true;
}
public override void handleEvent(PointerEvent evt, HitTestEntry entry) {
D.assert(debugHandleEvent(evt, entry));
if (evt is PointerDownEvent && isInteractive) {
_state._drag.addPointer((PointerDownEvent) evt);
_state._tap.addPointer((PointerDownEvent) evt);
}
}
public override void paint(PaintingContext context, Offset offset) {
Canvas canvas = context.canvas;
float currentValue = _state.position.value;
float currentReactionValue = _state._reaction.value;
float visualPosition = 0.0f;
switch (textDirection) {
case TextDirection.rtl:
visualPosition = 1.0f - currentValue;
break;
case TextDirection.ltr:
visualPosition = currentValue;
break;
}
Paint paint = new Paint() {color = Color.lerp(trackColor, activeColor, currentValue)};
Rect trackRect = Rect.fromLTWH(
offset.dx + (size.width - CupertinoSwitchUtils._kTrackWidth) / 2.0f,
offset.dy + (size.height - CupertinoSwitchUtils._kTrackHeight) / 2.0f,
CupertinoSwitchUtils._kTrackWidth,
CupertinoSwitchUtils._kTrackHeight
);
RRect trackRRect = RRect.fromRectAndRadius(trackRect, Radius.circular(CupertinoSwitchUtils._kTrackRadius));
canvas.drawRRect(trackRRect, paint);
float currentThumbExtension = CupertinoSwitchUtils._kExtension * currentReactionValue;
float thumbLeft = MathUtils.lerpNullableFloat(
trackRect.left + CupertinoSwitchUtils._kTrackInnerStart - CupertinoSwitchUtils._kRadius,
trackRect.left + CupertinoSwitchUtils._kTrackInnerEnd - CupertinoSwitchUtils._kRadius -
currentThumbExtension,
visualPosition
);
float thumbRight = MathUtils.lerpNullableFloat(
trackRect.left + CupertinoSwitchUtils._kTrackInnerStart + CupertinoSwitchUtils._kRadius +
currentThumbExtension,
trackRect.left + CupertinoSwitchUtils._kTrackInnerEnd + CupertinoSwitchUtils._kRadius,
visualPosition
);
float thumbCenterY = offset.dy + size.height / 2.0f;
Rect thumbBounds = Rect.fromLTRB(
thumbLeft,
thumbCenterY - CupertinoSwitchUtils._kRadius,
thumbRight,
thumbCenterY + CupertinoSwitchUtils._kRadius
);
context.pushClipRRect(needsCompositing, Offset.zero, thumbBounds, trackRRect,
(PaintingContext innerContext, Offset offset1) => {
CupertinoThumbPainter.switchThumb().paint(innerContext.canvas, thumbBounds);
});
}
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(
new FlagProperty("value", value: value, ifTrue: "checked", ifFalse: "unchecked", showName: true));
description.add(new FlagProperty("isInteractive", value: isInteractive, ifTrue: "enabled",
ifFalse: "disabled",
showName: true, defaultValue: true));
}
}
}

3
AwesomeUIWidgets/Assets/Scripts/RaycastableScene/custom_switch.cs.meta


fileFormatVersion: 2
guid: 8abc70c6c1384c48b94c787e263e242a
timeCreated: 1627611247
正在加载...
取消
保存