备份CatanBuilding瘦身独立工程
This commit is contained in:
63
Assets/Scripts/UI/FishingReward/FishIconRT.cs
Normal file
63
Assets/Scripts/UI/FishingReward/FishIconRT.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using cfg;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishIconRT : MonoBehaviour
|
||||
{
|
||||
RenderTexture rt;
|
||||
public Camera rtCamera;
|
||||
public Transform avatar;
|
||||
public int fieldOfView = 60;
|
||||
//鱼距离相机的位置
|
||||
public int fishPosZ = 20;
|
||||
GameObject goPrefab;
|
||||
private void Start()
|
||||
{
|
||||
transform.localScale = Vector3.one / transform.lossyScale.x;
|
||||
}
|
||||
public async void SetData(RawImage rawImage, FishData fishData)
|
||||
{
|
||||
RectTransform raw = rawImage.GetComponent<RectTransform>();
|
||||
rt = new RenderTexture((int)raw.rect.width, (int)raw.rect.height, 24, RenderTextureFormat.ARGB32);
|
||||
goPrefab = await Addressables.LoadAssetAsync<GameObject>(fishData.Fbx).Task;
|
||||
if (rt == null)
|
||||
{
|
||||
Addressables.Release(goPrefab);
|
||||
}
|
||||
else if (goPrefab != null)
|
||||
{
|
||||
rtCamera.fieldOfView = fieldOfView;
|
||||
rtCamera.enabled = true;
|
||||
Vector3 posWorld = new Vector3(fishData.TankPosition[0], fishData.TankPosition[1], fishData.TankPosition[2] + fishPosZ);
|
||||
var go = Instantiate(goPrefab, avatar);
|
||||
Fish fish = go.GetComponent<Fish>();
|
||||
fish.animator.transform.localPosition = Vector3.zero;
|
||||
go.transform.rotation = Quaternion.Euler(fishData.TankRotation[0], fishData.TankRotation[1], fishData.TankRotation[2]);
|
||||
go.transform.localScale = Vector3.one * fishData.TankScale;
|
||||
go.transform.localPosition = posWorld;
|
||||
rtCamera.targetTexture = rt;
|
||||
rawImage.texture = rt;
|
||||
rtCamera.Render();
|
||||
}
|
||||
else
|
||||
{
|
||||
rtCamera.enabled = false;
|
||||
}
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
rtCamera.targetTexture = null;
|
||||
if (rt != null)
|
||||
{
|
||||
rt.Release();
|
||||
Destroy(rt);
|
||||
rt = null;
|
||||
}
|
||||
if (goPrefab != null)
|
||||
{
|
||||
Addressables.Release(goPrefab);
|
||||
goPrefab = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/FishingReward/FishIconRT.cs.meta
Normal file
11
Assets/Scripts/UI/FishingReward/FishIconRT.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2a2219f3a992e247a1f4aacfe2fc83e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishingRewardInfoPopupPanel : MonoBehaviour
|
||||
{
|
||||
Button btn_close;
|
||||
private void Awake()
|
||||
{
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(OnClosePanel);
|
||||
}
|
||||
void OnClosePanel()
|
||||
{
|
||||
ShowNewMapEvent restartShowHomeUIEvent = new ShowNewMapEvent();
|
||||
GContext.Publish(restartShowHomeUIEvent);
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingRewardInfoPopupPanel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68a029e77b20f3e4ea4697bf1b5ed082
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1355
Assets/Scripts/UI/FishingReward/FishingRewardPanel.cs
Normal file
1355
Assets/Scripts/UI/FishingReward/FishingRewardPanel.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/Scripts/UI/FishingReward/FishingRewardPanel.cs.meta
Normal file
11
Assets/Scripts/UI/FishingReward/FishingRewardPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91bda471d3bfdaa43b5d502a6e4e0bf1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
74
Assets/Scripts/UI/FishingReward/FishingRewardPhoto.cs
Normal file
74
Assets/Scripts/UI/FishingReward/FishingRewardPhoto.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using GameCore;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityNative.Sharing;
|
||||
|
||||
public class FishingRewardPhoto : MonoBehaviour
|
||||
{
|
||||
Image icon_photo;
|
||||
Button btn_share;
|
||||
Button btn_back;
|
||||
public Action OnBackClick; // 用于通知外部点击返回按钮
|
||||
GameObject clickMask;
|
||||
byte[] bytes;
|
||||
IUnityNativeSharing adapter;
|
||||
string imageName = "TravelFish.png";
|
||||
string savePath;
|
||||
private void Awake()
|
||||
{
|
||||
btn_back = transform.Find("btn_back/btn_green").GetComponent<Button>();
|
||||
clickMask = transform.Find("clickMask").gameObject;
|
||||
btn_share = transform.Find("btn_share/btn_green").GetComponent<Button>();
|
||||
icon_photo = transform.Find("photo/icon_photo").GetComponent<Image>();
|
||||
clickMask.SetActive(false);
|
||||
btn_share.onClick.AddListener(OnClickInviteLink);
|
||||
btn_back.onClick.AddListener(OnClickBack);
|
||||
}
|
||||
|
||||
public void SetData(Sprite sprite, byte[] bytes)
|
||||
{
|
||||
icon_photo.sprite = sprite;
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
void OnClickBack()
|
||||
{
|
||||
OnBackClick?.Invoke(); // 调用外部传入的回调方法
|
||||
if (!string.IsNullOrEmpty(savePath))
|
||||
{
|
||||
CaptureImageSaver.DeleteImagePersistent(savePath);
|
||||
}
|
||||
}
|
||||
|
||||
void OnClickInviteLink()
|
||||
{
|
||||
//存图片
|
||||
clickMask.SetActive(true);
|
||||
CaptureImageSaver.SaveImagePersistent(bytes, imageName, MediaSaveCallback);
|
||||
clickMask.SetActive(false);
|
||||
|
||||
if (string.IsNullOrEmpty(savePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (adapter == null)
|
||||
{
|
||||
adapter = UnityNativeSharing.Create();
|
||||
}
|
||||
string invite = LocalizationMgr.GetText("UI_FishingSocialPanel_44");
|
||||
adapter.ShareScreenshotAndText(invite, savePath);
|
||||
}
|
||||
void MediaSaveCallback(bool success, string path)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
savePath = path;
|
||||
Debug.Log("Image saved to: " + path);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Failed to save image.");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/FishingReward/FishingRewardPhoto.cs.meta
Normal file
11
Assets/Scripts/UI/FishingReward/FishingRewardPhoto.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f3ebed01243b594fb4ea23501dcd893
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user