diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index dc01197..90ac5ca 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -1298,6 +1298,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 41794797} m_CullTransparentMesh: 1 +--- !u!1 &74037433 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 74037434} + - component: {fileID: 74037436} + - component: {fileID: 74037435} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &74037434 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 74037433} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 509438656} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: -427} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &74037435 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 74037433} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: New Text +--- !u!222 &74037436 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 74037433} + m_CullTransparentMesh: 1 --- !u!1 &75572015 GameObject: m_ObjectHideFlags: 0 @@ -4209,6 +4288,127 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 236057322} m_CullTransparentMesh: 1 +--- !u!1 &251376463 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 251376464} + - component: {fileID: 251376467} + - component: {fileID: 251376466} + - component: {fileID: 251376465} + m_Layer: 5 + m_Name: Button (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &251376464 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 251376463} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1021811798} + m_Father: {fileID: 509438656} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: 0, y: 449} + m_SizeDelta: {x: 0, y: 50} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &251376465 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 251376463} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 251376466} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &251376466 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 251376463} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &251376467 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 251376463} + m_CullTransparentMesh: 1 --- !u!1 &253257407 GameObject: m_ObjectHideFlags: 0 @@ -8198,81 +8398,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 418121315} m_CullTransparentMesh: 1 ---- !u!1 &419543684 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 419543685} - - component: {fileID: 419543687} - - component: {fileID: 419543686} - m_Layer: 5 - m_Name: Mask - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &419543685 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 419543684} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1617507956} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &419543686 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 419543684} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10917, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!222 &419543687 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 419543684} - m_CullTransparentMesh: 1 --- !u!1 &428545788 GameObject: m_ObjectHideFlags: 0 @@ -9893,6 +10018,83 @@ Transform: m_Children: [] m_Father: {fileID: 841691708} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &509438655 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 509438656} + - component: {fileID: 509438658} + - component: {fileID: 509438657} + m_Layer: 5 + m_Name: Image + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &509438656 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 509438655} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 251376464} + - {fileID: 74037434} + m_Father: {fileID: 1463334334} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: -50} + m_SizeDelta: {x: 200, y: -100} + m_Pivot: {x: 0, y: 0.5} +--- !u!114 &509438657 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 509438655} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &509438658 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 509438655} + m_CullTransparentMesh: 1 --- !u!1 &513219492 GameObject: m_ObjectHideFlags: 0 @@ -16609,7 +16811,7 @@ RectTransform: m_LocalScale: {x: 0, y: 0, z: 0} m_ConstrainProportionsScale: 0 m_Children: - - {fileID: 1617507956} + - {fileID: 1463334334} - {fileID: 1863547971} - {fileID: 1608300714} - {fileID: 2054237627} @@ -20349,6 +20551,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1019472754} m_CullTransparentMesh: 1 +--- !u!1 &1021811797 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1021811798} + - component: {fileID: 1021811800} + - component: {fileID: 1021811799} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1021811798 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1021811797} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 251376464} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1021811799 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1021811797} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 25 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 2 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u9009\u62E9\u6587\u4EF6\u5939" +--- !u!222 &1021811800 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1021811797} + m_CullTransparentMesh: 1 --- !u!1 &1024050255 GameObject: m_ObjectHideFlags: 0 @@ -28125,6 +28406,57 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1461008627} m_CullTransparentMesh: 1 +--- !u!1 &1463334333 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1463334334} + - component: {fileID: 1463334335} + m_Layer: 5 + m_Name: GeneratorSprite + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1463334334 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1463334333} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 509438656} + m_Father: {fileID: 838871187} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1463334335 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1463334333} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f8aa579054bbc3b499fc8c1ef3f58525, type: 3} + m_Name: + m_EditorClassIdentifier: + selectFolderButton: {fileID: 251376465} + statusText: {fileID: 74037435} --- !u!1 &1466376494 GameObject: m_ObjectHideFlags: 0 @@ -31001,65 +31333,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1615225086} m_CullTransparentMesh: 1 ---- !u!1 &1617507955 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1617507956} - - component: {fileID: 1617507958} - - component: {fileID: 1617507959} - m_Layer: 5 - m_Name: MapEditor - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1617507956 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1617507955} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 419543685} - m_Father: {fileID: 838871187} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -200.00006, y: 0} - m_SizeDelta: {x: -400, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &1617507958 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1617507955} - m_CullTransparentMesh: 1 ---- !u!114 &1617507959 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1617507955} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3} - m_Name: - m_EditorClassIdentifier: - m_ShowMaskGraphic: 1 --- !u!1 &1620280764 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/SpritesGenerator.meta b/Assets/Scripts/SpritesGenerator.meta new file mode 100644 index 0000000..94a4f76 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9396e3f6b1b620b44997b0101f816966 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/MultiGroupSpriteMerger.cs b/Assets/Scripts/SpritesGenerator/MultiGroupSpriteMerger.cs new file mode 100644 index 0000000..3760f20 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/MultiGroupSpriteMerger.cs @@ -0,0 +1,147 @@ +using UnityEngine; +using UnityEngine.UI; +using SFB; +using System.Collections.Generic; +using System.IO; +using System.Text.RegularExpressions; + +public class MultiGroupSpriteMerger : MonoBehaviour +{ + public Button selectFolderButton; + public Text statusText; + + void Start() + { + selectFolderButton.onClick.AddListener(OnSelectFolder); + } + + void OnSelectFolder() + { + var paths = StandaloneFileBrowser.OpenFolderPanel("选择包含序列帧图片的文件夹", "", false); + if (paths.Length > 0) + { + ProcessAllGroups(paths[0]); + } + } + + void ProcessAllGroups(string folderPath) + { + statusText.text = "开始读取图片..."; + + string[] files = Directory.GetFiles(folderPath, "*.png"); + Dictionary>> groupMap = new(); + + Regex regex = new Regex(@"(\d+)_(\d+)\.png"); + + foreach (var path in files) + { + string fileName = Path.GetFileName(path); + Match match = regex.Match(fileName); + if (!match.Success) continue; + + int x = int.Parse(match.Groups[1].Value); + int groupIndex = (x - 1) / 8 + 1; + int direction = (x - 1) % 8 + 1; + + Texture2D tex = new Texture2D(2, 2); + if (!tex.LoadImage(File.ReadAllBytes(path))) + { + Debug.LogWarning($"加载图片失败: {fileName}"); + continue; + } + + tex.name = fileName; + + if (!groupMap.ContainsKey(groupIndex)) + groupMap[groupIndex] = new Dictionary>(); + + if (!groupMap[groupIndex].ContainsKey(direction)) + groupMap[groupIndex][direction] = new List(); + + groupMap[groupIndex][direction].Add(tex); + } + + int exportedCount = 0; + + foreach (var group in groupMap) + { + int groupId = group.Key; + var directions = group.Value; + + List rowHeights = new(); + List> rows = new(); + List rowWidths = new(); + + foreach (var dir in directions) + { + var frames = dir.Value; + int maxH = 0, totalW = 0; + + // 排序帧 + frames.Sort((a, b) => + { + var ma = Regex.Match(a.name, @"\d+_(\d+)"); + var mb = Regex.Match(b.name, @"\d+_(\d+)"); + return int.Parse(ma.Groups[1].Value).CompareTo(int.Parse(mb.Groups[1].Value)); + }); + + foreach (var tex in frames) + { + totalW += tex.width; + maxH = Mathf.Max(maxH, tex.height); + } + + rowWidths.Add(totalW); + rowHeights.Add(maxH); + rows.Add(frames); + } + + int totalHeight = 0; + foreach (int h in rowHeights) totalHeight += h; + + int totalWidth = 0; + foreach (int w in rowWidths) totalWidth = Mathf.Max(totalWidth, w); + + Texture2D result = new Texture2D(totalWidth, totalHeight, TextureFormat.RGBA32, false); + Color[] clear = new Color[totalWidth * totalHeight]; + for (int i = 0; i < clear.Length; i++) clear[i] = new Color(0, 0, 0, 0); + result.SetPixels(clear); + + int yOffset = totalHeight; + for (int row = 0; row < rows.Count; row++) + { + List frames = rows[row]; + int xOffset = 0; + int rowHeight = rowHeights[row]; + yOffset -= rowHeight; + + foreach (var tex in frames) + { + try + { + Color[] pixels = tex.GetPixels(); + if (pixels.Length != tex.width * tex.height) + { + Debug.LogWarning($"跳过尺寸异常图像: {tex.name}"); + continue; + } + result.SetPixels(xOffset, yOffset + (rowHeight - tex.height), tex.width, tex.height, pixels); + xOffset += tex.width; + } + catch (System.Exception ex) + { + Debug.LogError($"绘图出错: {tex.name} - {ex.Message}"); + } + } + } + + result.Apply(); + string savePath = Path.Combine(folderPath, $"combined_group_{groupId}.png"); + File.WriteAllBytes(savePath, result.EncodeToPNG()); + Debug.Log($"导出完成:{savePath}"); + exportedCount++; + } + + statusText.text = $"完成,共导出 {exportedCount} 张大图"; + } +} diff --git a/Assets/Scripts/SpritesGenerator/MultiGroupSpriteMerger.cs.meta b/Assets/Scripts/SpritesGenerator/MultiGroupSpriteMerger.cs.meta new file mode 100644 index 0000000..e08a076 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/MultiGroupSpriteMerger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f8aa579054bbc3b499fc8c1ef3f58525 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser.meta new file mode 100644 index 0000000..7c1512c --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8d29511ce36989944be6e7dca6f1702a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/IStandaloneFileBrowser.cs b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/IStandaloneFileBrowser.cs new file mode 100644 index 0000000..19c089d --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/IStandaloneFileBrowser.cs @@ -0,0 +1,13 @@ +using System; + +namespace SFB { + public interface IStandaloneFileBrowser { + string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect); + string[] OpenFolderPanel(string title, string directory, bool multiselect); + string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions); + + void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action cb); + void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action cb); + void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action cb); + } +} diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/IStandaloneFileBrowser.cs.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/IStandaloneFileBrowser.cs.meta new file mode 100644 index 0000000..297c5e8 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/IStandaloneFileBrowser.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7609f7b6787a54496aa41a3053fcc76a +timeCreated: 1483902788 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins.meta new file mode 100644 index 0000000..f307639 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 07e5c61c253f35142bbe67dd902af47f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux.meta new file mode 100644 index 0000000..12e971a --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 82666e520ab4d4cf08bebbb8059cd6f4 +folderAsset: yes +timeCreated: 1538224809 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux/x86_64.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux/x86_64.meta new file mode 100644 index 0000000..7f52bde --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: bd198408642944765b9305bd99404136 +folderAsset: yes +timeCreated: 1538230728 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux/x86_64/libStandaloneFileBrowser.so b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux/x86_64/libStandaloneFileBrowser.so new file mode 100644 index 0000000..344084e Binary files /dev/null and b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux/x86_64/libStandaloneFileBrowser.so differ diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux/x86_64/libStandaloneFileBrowser.so.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux/x86_64/libStandaloneFileBrowser.so.meta new file mode 100644 index 0000000..f925612 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Linux/x86_64/libStandaloneFileBrowser.so.meta @@ -0,0 +1,126 @@ +fileFormatVersion: 2 +guid: b8c465928f1784a3fac8dc3766f7201c +timeCreated: 1538230728 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux: 1 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude SamsungTV: 1 + Exclude Tizen: 1 + Exclude WebGL: 1 + Exclude Win: 0 + Exclude Win64: 0 + Exclude iOS: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: Linux + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Samsung TV: SamsungTV + second: + enabled: 0 + settings: + STV_MODEL: STANDARD_15 + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll new file mode 100644 index 0000000..a5164a5 Binary files /dev/null and b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll differ diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll.meta new file mode 100644 index 0000000..b197a63 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll.meta @@ -0,0 +1,145 @@ +fileFormatVersion: 2 +guid: 2d82be0ece6bbcc4d874137f47fa637f +timeCreated: 1491979494 +licenseType: Pro +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 0 + Exclude Win64: 0 + Exclude iOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 1 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle.meta new file mode 100644 index 0000000..c7bdac6 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle.meta @@ -0,0 +1,40 @@ +fileFormatVersion: 2 +guid: 110fdfb459db4fc448a2ccd37e200fa4 +folderAsset: yes +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Standalone: OSXIntel + second: + enabled: 1 + settings: {} + - first: + Standalone: OSXIntel64 + second: + enabled: 1 + settings: {} + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents.meta new file mode 100644 index 0000000..37ed2fc --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 996ea0b0fb9804844ba9595686ee3e7a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/Info.plist b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/Info.plist new file mode 100644 index 0000000..52c479c --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/Info.plist @@ -0,0 +1,46 @@ + + + + + BuildMachineOSBuild + 18A391 + CFBundleDevelopmentRegion + English + CFBundleExecutable + StandaloneFileBrowser + CFBundleIdentifier + com.gkngkc.sfb + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + StandaloneFileBrowser + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1.0 + CSResourcesFileMapped + + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 10A255 + DTPlatformVersion + GM + DTSDKBuild + 18A384 + DTSDKName + macosx10.14 + DTXcode + 1000 + DTXcodeBuild + 10A255 + + diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/Info.plist.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/Info.plist.meta new file mode 100644 index 0000000..22c9f90 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/Info.plist.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce685769797f44046afa3e567860c94c +timeCreated: 1505756861 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/MacOS.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/MacOS.meta new file mode 100644 index 0000000..bd2d540 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/MacOS.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a5a66f5db020f344c9327188aec2c060 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/MacOS/StandaloneFileBrowser b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/MacOS/StandaloneFileBrowser new file mode 100644 index 0000000..caf2b68 Binary files /dev/null and b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/MacOS/StandaloneFileBrowser differ diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/MacOS/StandaloneFileBrowser.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/MacOS/StandaloneFileBrowser.meta new file mode 100644 index 0000000..a298a74 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/MacOS/StandaloneFileBrowser.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ddf122e0e89124ce78aacfeecb3ec554 +timeCreated: 1508179371 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.jslib b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.jslib new file mode 100644 index 0000000..1198f38 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.jslib @@ -0,0 +1,90 @@ +var StandaloneFileBrowserWebGLPlugin = { + // Open file. + // gameObjectNamePtr: Unique GameObject name. Required for calling back unity with SendMessage. + // methodNamePtr: Callback method name on given GameObject. + // filter: Filter files. Example filters: + // Match all image files: "image/*" + // Match all video files: "video/*" + // Match all audio files: "audio/*" + // Custom: ".plist, .xml, .yaml" + // multiselect: Allows multiple file selection + UploadFile: function(gameObjectNamePtr, methodNamePtr, filterPtr, multiselect) { + gameObjectName = Pointer_stringify(gameObjectNamePtr); + methodName = Pointer_stringify(methodNamePtr); + filter = Pointer_stringify(filterPtr); + + // Delete if element exist + var fileInput = document.getElementById(gameObjectName) + if (fileInput) { + document.body.removeChild(fileInput); + } + + fileInput = document.createElement('input'); + fileInput.setAttribute('id', gameObjectName); + fileInput.setAttribute('type', 'file'); + fileInput.setAttribute('style','display:none;'); + fileInput.setAttribute('style','visibility:hidden;'); + if (multiselect) { + fileInput.setAttribute('multiple', ''); + } + if (filter) { + fileInput.setAttribute('accept', filter); + } + fileInput.onclick = function (event) { + // File dialog opened + this.value = null; + }; + fileInput.onchange = function (event) { + // multiselect works + var urls = []; + for (var i = 0; i < event.target.files.length; i++) { + urls.push(URL.createObjectURL(event.target.files[i])); + } + // File selected + SendMessage(gameObjectName, methodName, urls.join()); + + // Remove after file selected + document.body.removeChild(fileInput); + } + document.body.appendChild(fileInput); + + document.onmouseup = function() { + fileInput.click(); + document.onmouseup = null; + } + }, + + // Save file + // DownloadFile method does not open SaveFileDialog like standalone builds, its just allows user to download file + // gameObjectNamePtr: Unique GameObject name. Required for calling back unity with SendMessage. + // methodNamePtr: Callback method name on given GameObject. + // filenamePtr: Filename with extension + // byteArray: byte[] + // byteArraySize: byte[].Length + DownloadFile: function(gameObjectNamePtr, methodNamePtr, filenamePtr, byteArray, byteArraySize) { + gameObjectName = Pointer_stringify(gameObjectNamePtr); + methodName = Pointer_stringify(methodNamePtr); + filename = Pointer_stringify(filenamePtr); + + var bytes = new Uint8Array(byteArraySize); + for (var i = 0; i < byteArraySize; i++) { + bytes[i] = HEAPU8[byteArray + i]; + } + + var downloader = window.document.createElement('a'); + downloader.setAttribute('id', gameObjectName); + downloader.href = window.URL.createObjectURL(new Blob([bytes], { type: 'application/octet-stream' })); + downloader.download = filename; + document.body.appendChild(downloader); + + document.onmouseup = function() { + downloader.click(); + document.body.removeChild(downloader); + document.onmouseup = null; + + SendMessage(gameObjectName, methodName); + } + } +}; + +mergeInto(LibraryManager.library, StandaloneFileBrowserWebGLPlugin); \ No newline at end of file diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.jslib.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.jslib.meta new file mode 100644 index 0000000..9ba582b --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.jslib.meta @@ -0,0 +1,96 @@ +fileFormatVersion: 2 +guid: 265aaf20a6d564e0fb00a9c4a7a9c300 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: WebGL + second: + enabled: 1 + settings: {} + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + WebGL: WebGL + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/System.Windows.Forms.dll b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/System.Windows.Forms.dll new file mode 100644 index 0000000..f6d8475 Binary files /dev/null and b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/System.Windows.Forms.dll differ diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/System.Windows.Forms.dll.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/System.Windows.Forms.dll.meta new file mode 100644 index 0000000..f757441 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Plugins/System.Windows.Forms.dll.meta @@ -0,0 +1,145 @@ +fileFormatVersion: 2 +guid: 7d459a96865cc4aaab657012c6dc4833 +timeCreated: 1491979494 +licenseType: Pro +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 0 + Exclude Win64: 0 + Exclude iOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 1 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample.meta new file mode 100644 index 0000000..3c5d69f --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 435c74f62ab57b448adeeb37cbc0f96b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSample.cs b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSample.cs new file mode 100644 index 0000000..77e427f --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSample.cs @@ -0,0 +1,119 @@ +using System.Collections; +using UnityEngine; +using SFB; + +public class BasicSample : MonoBehaviour { + private string _path; + + void OnGUI() { + var guiScale = new Vector3(Screen.width / 800.0f, Screen.height / 600.0f, 1.0f); + GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, guiScale); + + GUILayout.Space(20); + GUILayout.BeginHorizontal(); + GUILayout.Space(20); + GUILayout.BeginVertical(); + + // Open File Samples + + if (GUILayout.Button("Open File")) { + WriteResult(StandaloneFileBrowser.OpenFilePanel("Open File", "", "", false)); + } + GUILayout.Space(5); + if (GUILayout.Button("Open File Async")) { + StandaloneFileBrowser.OpenFilePanelAsync("Open File", "", "", false, (string[] paths) => { WriteResult(paths); }); + } + GUILayout.Space(5); + if (GUILayout.Button("Open File Multiple")) { + WriteResult(StandaloneFileBrowser.OpenFilePanel("Open File", "", "", true)); + } + GUILayout.Space(5); + if (GUILayout.Button("Open File Extension")) { + WriteResult(StandaloneFileBrowser.OpenFilePanel("Open File", "", "txt", true)); + } + GUILayout.Space(5); + if (GUILayout.Button("Open File Directory")) { + WriteResult(StandaloneFileBrowser.OpenFilePanel("Open File", Application.dataPath, "", true)); + } + GUILayout.Space(5); + if (GUILayout.Button("Open File Filter")) { + var extensions = new [] { + new ExtensionFilter("Image Files", "png", "jpg", "jpeg" ), + new ExtensionFilter("Sound Files", "mp3", "wav" ), + new ExtensionFilter("All Files", "*" ), + }; + WriteResult(StandaloneFileBrowser.OpenFilePanel("Open File", "", extensions, true)); + } + + GUILayout.Space(15); + + // Open Folder Samples + + if (GUILayout.Button("Open Folder")) { + var paths = StandaloneFileBrowser.OpenFolderPanel("Select Folder", "", true); + WriteResult(paths); + } + GUILayout.Space(5); + if (GUILayout.Button("Open Folder Async")) { + StandaloneFileBrowser.OpenFolderPanelAsync("Select Folder", "", true, (string[] paths) => { WriteResult(paths); }); + } + GUILayout.Space(5); + if (GUILayout.Button("Open Folder Directory")) { + var paths = StandaloneFileBrowser.OpenFolderPanel("Select Folder", Application.dataPath, true); + WriteResult(paths); + } + + GUILayout.Space(15); + + // Save File Samples + + if (GUILayout.Button("Save File")) { + _path = StandaloneFileBrowser.SaveFilePanel("Save File", "", "", ""); + } + GUILayout.Space(5); + if (GUILayout.Button("Save File Async")) { + StandaloneFileBrowser.SaveFilePanelAsync("Save File", "", "", "", (string path) => { WriteResult(path); }); + } + GUILayout.Space(5); + if (GUILayout.Button("Save File Default Name")) { + _path = StandaloneFileBrowser.SaveFilePanel("Save File", "", "MySaveFile", ""); + } + GUILayout.Space(5); + if (GUILayout.Button("Save File Default Name Ext")) { + _path = StandaloneFileBrowser.SaveFilePanel("Save File", "", "MySaveFile", "dat"); + } + GUILayout.Space(5); + if (GUILayout.Button("Save File Directory")) { + _path = StandaloneFileBrowser.SaveFilePanel("Save File", Application.dataPath, "", ""); + } + GUILayout.Space(5); + if (GUILayout.Button("Save File Filter")) { + // Multiple save extension filters with more than one extension support. + var extensionList = new [] { + new ExtensionFilter("Binary", "bin"), + new ExtensionFilter("Text", "txt"), + }; + _path = StandaloneFileBrowser.SaveFilePanel("Save File", "", "MySaveFile", extensionList); + } + + GUILayout.EndVertical(); + GUILayout.Space(20); + GUILayout.Label(_path); + GUILayout.EndHorizontal(); + } + + public void WriteResult(string[] paths) { + if (paths.Length == 0) { + return; + } + + _path = ""; + foreach (var p in paths) { + _path += p + "\n"; + } + } + + public void WriteResult(string path) { + _path = path; + } +} diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSample.cs.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSample.cs.meta new file mode 100644 index 0000000..9319b42 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSample.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5148400295519405d82bb0fa65246ea2 +timeCreated: 1483902788 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSampleScene.unity b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSampleScene.unity new file mode 100644 index 0000000..75c88fa --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSampleScene.unity @@ -0,0 +1,248 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 10 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 1 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 0 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &382763637 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 382763642} + - component: {fileID: 382763641} + - component: {fileID: 382763640} + - component: {fileID: 382763639} + - component: {fileID: 382763638} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &382763638 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 382763637} + m_Enabled: 1 +--- !u!124 &382763639 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 382763637} + m_Enabled: 1 +--- !u!92 &382763640 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 382763637} + m_Enabled: 1 +--- !u!20 &382763641 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 382763637} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &382763642 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 382763637} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &986049433 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 986049435} + - component: {fileID: 986049434} + m_Layer: 0 + m_Name: GameObject + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &986049434 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 986049433} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5148400295519405d82bb0fa65246ea2, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &986049435 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 986049433} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSampleScene.unity.meta b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSampleScene.unity.meta new file mode 100644 index 0000000..e012535 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/BasicSampleScene.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d97280fe82b874466870f709c3315d41 +timeCreated: 1483902786 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/CanvasSampleOpenFileImage.cs b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/CanvasSampleOpenFileImage.cs new file mode 100644 index 0000000..4fb1351 --- /dev/null +++ b/Assets/Scripts/SpritesGenerator/StandaloneFileBrowser/Sample/CanvasSampleOpenFileImage.cs @@ -0,0 +1,53 @@ +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; +using UnityEngine.UI; +using UnityEngine.EventSystems; +using SFB; + +[RequireComponent(typeof(Button))] +public class CanvasSampleOpenFileImage : MonoBehaviour, IPointerDownHandler { + public RawImage output; + +#if UNITY_WEBGL && !UNITY_EDITOR + // + // WebGL + // + [DllImport("__Internal")] + private static extern void UploadFile(string gameObjectName, string methodName, string filter, bool multiple); + + public void OnPointerDown(PointerEventData eventData) { + UploadFile(gameObject.name, "OnFileUpload", ".png, .jpg", false); + } + + // Called from browser + public void OnFileUpload(string url) { + StartCoroutine(OutputRoutine(url)); + } +#else + // + // Standalone platforms & editor + // + public void OnPointerDown(PointerEventData eventData) { } + + void Start() { + var button = GetComponent