添加设计界面操作按钮
parent
08b89a69b3
commit
542c7efb98
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
|
@ -0,0 +1,130 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3192669eb8ba7b644a2cd360aac2b18d
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 13
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
flipGreenChannel: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
ignoreMipmapLimit: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: 1
|
||||||
|
wrapW: 0
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 8
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
swizzle: 50462976
|
||||||
|
cookieLightType: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Android
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
customData:
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID: 5e97eb03825dee720800000000000000
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spriteCustomMetadata:
|
||||||
|
entries: []
|
||||||
|
nameFileIdTable: {}
|
||||||
|
mipmapLimitGroupName:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
|
@ -0,0 +1,130 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 180fec64c16a16d4aa19797cc83ebcf9
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 13
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
flipGreenChannel: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
ignoreMipmapLimit: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: 1
|
||||||
|
wrapW: 0
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 8
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
swizzle: 50462976
|
||||||
|
cookieLightType: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Android
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
customData:
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID: 5e97eb03825dee720800000000000000
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spriteCustomMetadata:
|
||||||
|
entries: []
|
||||||
|
nameFileIdTable: {}
|
||||||
|
mipmapLimitGroupName:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
|
@ -0,0 +1,130 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 56449ac85a79efd4693d25f87617b488
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 13
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
flipGreenChannel: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
ignoreMipmapLimit: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: 1
|
||||||
|
wrapW: 0
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 8
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
swizzle: 50462976
|
||||||
|
cookieLightType: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Android
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
customData:
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID: 5e97eb03825dee720800000000000000
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spriteCustomMetadata:
|
||||||
|
entries: []
|
||||||
|
nameFileIdTable: {}
|
||||||
|
mipmapLimitGroupName:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,7 @@
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
using ZGame;
|
using ZGame;
|
||||||
|
|
||||||
namespace HK.FUJIFILM
|
namespace HK.FUJIFILM
|
||||||
|
@ -9,9 +10,12 @@ namespace HK.FUJIFILM
|
||||||
{
|
{
|
||||||
[SerializeField] private Button btnToUp;
|
[SerializeField] private Button btnToUp;
|
||||||
[SerializeField] private Button btnToDown;
|
[SerializeField] private Button btnToDown;
|
||||||
[SerializeField] private Button btnRotate;
|
[SerializeField] private Button btnRRotate;
|
||||||
|
[SerializeField] private Button btnLRotate;
|
||||||
[SerializeField] private Button btnDelete;
|
[SerializeField] private Button btnDelete;
|
||||||
[SerializeField] private Button btnClose;
|
[SerializeField] private Button btnClose;
|
||||||
|
[SerializeField] private Button btnHCenter;
|
||||||
|
[SerializeField] private Button btnVCenter;
|
||||||
|
|
||||||
CanvasGroup canvasGroup;
|
CanvasGroup canvasGroup;
|
||||||
|
|
||||||
|
@ -25,18 +29,26 @@ namespace HK.FUJIFILM
|
||||||
|
|
||||||
btnToUp = GetValue<Button>("btnToUp");
|
btnToUp = GetValue<Button>("btnToUp");
|
||||||
btnToDown = GetValue<Button>("btnToDown");
|
btnToDown = GetValue<Button>("btnToDown");
|
||||||
btnRotate = GetValue<Button>("btnRotate");
|
btnRRotate = GetValue<Button>("btnRRotate");
|
||||||
|
btnLRotate = GetValue<Button>("btnLRotate");
|
||||||
btnDelete = GetValue<Button>("btnDelete");
|
btnDelete = GetValue<Button>("btnDelete");
|
||||||
btnClose = GetValue<Button>("btnClose");
|
btnClose = GetValue<Button>("btnClose");
|
||||||
|
btnHCenter = GetValue<Button>("btnHCenter");
|
||||||
|
btnVCenter = GetValue<Button>("btnVCenter");
|
||||||
|
|
||||||
btnToUp.onClick.AddListener(OnClickbtnToUp);
|
btnToUp.onClick.AddListener(OnClickbtnToUp);
|
||||||
btnToDown.onClick.AddListener(OnClickbtnToDown);
|
btnToDown.onClick.AddListener(OnClickbtnToDown);
|
||||||
btnRotate.onClick.AddListener(OnClickbtnRotate);
|
btnRRotate.onClick.AddListener(OnClickbtnRRotate);
|
||||||
|
btnLRotate.onClick.AddListener(OnClickbtnLRotate);
|
||||||
btnDelete.onClick.AddListener(OnClickbtnDelete);
|
btnDelete.onClick.AddListener(OnClickbtnDelete);
|
||||||
|
btnHCenter.onClick.AddListener(OnClickbtnHCenter);
|
||||||
|
btnVCenter.onClick.AddListener(OnClickbtnVCenter);
|
||||||
btnClose.onClick.AddListener(OnClickbtnClose);
|
btnClose.onClick.AddListener(OnClickbtnClose);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
canvas = GetComponentInParent<Canvas>();
|
||||||
|
_imageRect = transform.GetChild(1).GetComponent<RectTransform>();
|
||||||
canvasGroup = GetComponent<CanvasGroup>();
|
canvasGroup = GetComponent<CanvasGroup>();
|
||||||
Close();
|
Close();
|
||||||
EventManager.Instance.Subscribe(PhotoItemOperationEventArgs.EventId, PhotoItemOperationEvent);
|
EventManager.Instance.Subscribe(PhotoItemOperationEventArgs.EventId, PhotoItemOperationEvent);
|
||||||
|
@ -44,8 +56,7 @@ namespace HK.FUJIFILM
|
||||||
|
|
||||||
private void PhotoItemOperationEvent(object sender, GameEventArgs e)
|
private void PhotoItemOperationEvent(object sender, GameEventArgs e)
|
||||||
{
|
{
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
var args = e as PhotoItemOperationEventArgs;
|
var args = e as PhotoItemOperationEventArgs;
|
||||||
if (args == null)
|
if (args == null)
|
||||||
{
|
{
|
||||||
|
@ -53,11 +64,105 @@ namespace HK.FUJIFILM
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.isStart)
|
if (args.isStart)
|
||||||
|
{
|
||||||
|
// 1. 获取鼠标点击的屏幕坐标
|
||||||
|
Vector2 clickScreenPos = Input.mousePosition;
|
||||||
|
|
||||||
|
// 2. 应用偏移量(让 Image 位置更灵活)
|
||||||
|
clickScreenPos += clickOffset;
|
||||||
|
|
||||||
|
// 3. (可选)限制 Image 在屏幕内
|
||||||
|
if (clampToScreen)
|
||||||
|
{
|
||||||
|
clickScreenPos = ClampPosToScreen(clickScreenPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 根据 Canvas 模式,设置 Image 最终位置
|
||||||
|
SetImagePosition(clickScreenPos);
|
||||||
|
|
||||||
Open(args.target);
|
Open(args.target);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Canvas canvas;
|
||||||
|
private RectTransform _imageRect;
|
||||||
|
[SerializeField] int screenMargin = 10;
|
||||||
|
[SerializeField] bool clampToScreen = true;
|
||||||
|
[SerializeField] Vector2 clickOffset = Vector2.zero;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 限制位置在屏幕内,防止 Image 超出视野
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="originalPos">原始点击位置</param>
|
||||||
|
/// <returns>限制后的位置</returns>
|
||||||
|
private Vector2 ClampPosToScreen(Vector2 originalPos)
|
||||||
|
{
|
||||||
|
// 计算 Image 自身的实际尺寸(考虑缩放)
|
||||||
|
Vector2 imageRealSize = new Vector2(
|
||||||
|
_imageRect.rect.width * Mathf.Abs(_imageRect.localScale.x),
|
||||||
|
_imageRect.rect.height * Mathf.Abs(_imageRect.localScale.y)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 计算屏幕可显示的边界(留空 margin)
|
||||||
|
float minX = screenMargin + (imageRealSize.x / 2); // 左边界(加 Image 半宽,避免左半部分超出)
|
||||||
|
float maxX = Screen.width - screenMargin - (imageRealSize.x / 2); // 右边界
|
||||||
|
float minY = screenMargin + (imageRealSize.y / 2); // 下边界
|
||||||
|
float maxY = Screen.height - screenMargin - (imageRealSize.y / 2); // 上边界
|
||||||
|
|
||||||
|
// 限制位置在边界内
|
||||||
|
return new Vector2(
|
||||||
|
Mathf.Clamp(originalPos.x, minX, maxX),
|
||||||
|
Mathf.Clamp(originalPos.y, minY, maxY)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据 Canvas 渲染模式,设置 Image 到目标位置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetScreenPos">目标屏幕坐标</param>
|
||||||
|
private void SetImagePosition(Vector2 targetScreenPos)
|
||||||
|
{
|
||||||
|
switch (canvas.renderMode)
|
||||||
|
{
|
||||||
|
// 1. 最常用:Screen Space - Overlay 模式(直接用屏幕坐标)
|
||||||
|
case RenderMode.ScreenSpaceOverlay:
|
||||||
|
_imageRect.position = targetScreenPos;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 2. Screen Space - Camera 模式(需通过相机转换坐标)
|
||||||
|
case RenderMode.ScreenSpaceCamera:
|
||||||
|
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(
|
||||||
|
canvas.GetComponent<RectTransform>(), // Canvas 的 RectTransform
|
||||||
|
targetScreenPos, // 目标屏幕位置
|
||||||
|
canvas.worldCamera, // Canvas 关联的相机
|
||||||
|
out Vector2 canvasLocalPos // 转换后的 Canvas 局部坐标
|
||||||
|
))
|
||||||
|
{
|
||||||
|
_imageRect.localPosition = canvasLocalPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 3. World Space 模式(UI 作为3D物体,需转换为世界坐标)
|
||||||
|
case RenderMode.WorldSpace:
|
||||||
|
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(
|
||||||
|
_imageRect, // Image 自身的 RectTransform
|
||||||
|
targetScreenPos, // 目标屏幕位置
|
||||||
|
canvas.worldCamera, // Canvas 关联的相机
|
||||||
|
out Vector3 worldPos // 转换后的世界坐标
|
||||||
|
))
|
||||||
|
{
|
||||||
|
// 保持 Image 的 Z 轴位置不变(避免前后层叠问题)
|
||||||
|
worldPos.z = _imageRect.position.z;
|
||||||
|
_imageRect.position = worldPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region AutoGen_Method
|
#region AutoGen_Method
|
||||||
|
|
||||||
private void OnClickbtnToUp()
|
private void OnClickbtnToUp()
|
||||||
|
@ -69,13 +174,35 @@ namespace HK.FUJIFILM
|
||||||
|
|
||||||
private void OnClickbtnToDown()
|
private void OnClickbtnToDown()
|
||||||
{
|
{
|
||||||
var siblingIndex = (target.transform.GetSiblingIndex() - 1) >= 0 ? target.transform.GetSiblingIndex() : 0;
|
var index = target.transform.GetSiblingIndex() - 1;
|
||||||
|
var siblingIndex = index >= 0 ? index : 0;
|
||||||
target.transform.SetSiblingIndex(siblingIndex);
|
target.transform.SetSiblingIndex(siblingIndex);
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClickbtnRotate()
|
private void OnClickbtnRRotate()
|
||||||
{
|
{
|
||||||
|
target.transform.localEulerAngles += new Vector3(0f, 0f, 90f);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClickbtnLRotate()
|
||||||
|
{
|
||||||
|
target.transform.localEulerAngles -= new Vector3(0f, 0f, 90f);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClickbtnVCenter()
|
||||||
|
{
|
||||||
|
var rectTransform = target.GetComponent<RectTransform>();
|
||||||
|
rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, 0f);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClickbtnHCenter()
|
||||||
|
{
|
||||||
|
var rectTransform = target.GetComponent<RectTransform>();
|
||||||
|
rectTransform.anchoredPosition = new Vector2(0f, rectTransform.anchoredPosition.y);
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,18 +243,20 @@ namespace HK.FUJIFILM
|
||||||
public override void OnDispose()
|
public override void OnDispose()
|
||||||
{
|
{
|
||||||
base.OnDispose();
|
base.OnDispose();
|
||||||
|
EventManager.Instance.Unsubscribe(PhotoItemOperationEventArgs.EventId, PhotoItemOperationEvent);
|
||||||
|
|
||||||
#region AutoGen_Dispose
|
#region AutoGen_Dispose
|
||||||
|
|
||||||
btnToUp.onClick.RemoveListener(OnClickbtnToUp);
|
btnToUp.onClick.RemoveListener(OnClickbtnToUp);
|
||||||
btnToDown.onClick.RemoveListener(OnClickbtnToDown);
|
btnToDown.onClick.RemoveListener(OnClickbtnToDown);
|
||||||
btnRotate.onClick.RemoveListener(OnClickbtnRotate);
|
btnRRotate.onClick.RemoveListener(OnClickbtnRRotate);
|
||||||
|
btnLRotate.onClick.RemoveListener(OnClickbtnLRotate);
|
||||||
btnDelete.onClick.RemoveListener(OnClickbtnDelete);
|
btnDelete.onClick.RemoveListener(OnClickbtnDelete);
|
||||||
btnClose.onClick.RemoveListener(OnClickbtnClose);
|
btnClose.onClick.RemoveListener(OnClickbtnClose);
|
||||||
|
|
||||||
btnToUp = null;
|
btnToUp = null;
|
||||||
btnToDown = null;
|
btnToDown = null;
|
||||||
btnRotate = null;
|
btnRRotate = null;
|
||||||
btnDelete = null;
|
btnDelete = null;
|
||||||
btnClose = null;
|
btnClose = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue