118 lines
3.8 KiB
C#
118 lines
3.8 KiB
C#
using System;
|
|
using UnityEngine.UI;
|
|
using UnityEngine;
|
|
using ZXL.Helper;
|
|
using ZXL.Manager;
|
|
using ZXL.Scripts.UI;
|
|
|
|
namespace ZXL
|
|
{
|
|
public class PushModelUILogic : UIBase
|
|
{
|
|
public Button btn_ModelFile;
|
|
public InputField inp_ModelName;
|
|
public Dropdown dro_BiaoQian;
|
|
public Dropdown dro_LeiXing;
|
|
public RawImage raw_Min;
|
|
public Text txt_ScaleX;
|
|
public Text txt_ScaleY;
|
|
public Text txt_ScaleZ;
|
|
public InputField inp_BeiZhu;
|
|
public RawImage raw_Max;
|
|
public Button btn_Push;
|
|
public Button btnCancel;
|
|
public Transform parent;
|
|
public Camera cam;
|
|
|
|
public AssetTag assetTag = AssetTag.个人;
|
|
|
|
void Awake()
|
|
{
|
|
btn_ModelFile = transform.FindChildDeep<Button>("btn_ModelFile");
|
|
inp_ModelName = transform.FindChildDeep<InputField>("inp_ModelName");
|
|
dro_BiaoQian = transform.FindChildDeep<Dropdown>("dro_BiaoQian");
|
|
dro_LeiXing = transform.FindChildDeep<Dropdown>("dro_LeiXing");
|
|
raw_Min = transform.FindChildDeep<RawImage>("raw_Min");
|
|
txt_ScaleX = transform.FindChildDeep<Text>("txt_ScaleX");
|
|
txt_ScaleY = transform.FindChildDeep<Text>("txt_ScaleY");
|
|
txt_ScaleZ = transform.FindChildDeep<Text>("txt_ScaleZ");
|
|
inp_BeiZhu = transform.FindChildDeep<InputField>("inp_BeiZhu");
|
|
raw_Max = transform.FindChildDeep<RawImage>("raw_Max");
|
|
btn_Push = transform.FindChildDeep<Button>("btn_Push");
|
|
btnCancel = transform.FindChildDeep<Button>("btnCancel");
|
|
parent = transform.FindChildDeep<Transform>("parent");
|
|
cam = transform.FindChildDeep<Camera>("PushModelCamera");
|
|
|
|
btn_ModelFile.onClick.AddListener(OnClickbtn_ModelFile);
|
|
btn_Push.onClick.AddListener(OnClickbtn_Push);
|
|
btnCancel.onClick.AddListener(OnClickbtn_Cancel);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
AssetManager.Instance.SetCamera(cam);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
for (var i = 0; i < parent.childCount; i++)
|
|
{
|
|
GameObject.Destroy(parent.GetChild(i).gameObject);
|
|
}
|
|
}
|
|
|
|
private void OnClickbtn_ModelFile()
|
|
{
|
|
AssetManager.Instance.PushAsset("", parent.gameObject, assetTag, Callback);
|
|
}
|
|
|
|
string fileName;
|
|
string filePathName;
|
|
GameObject go;
|
|
|
|
private void Callback(string arg1, string arg2, GameObject arg3)
|
|
{
|
|
fileName = arg1;
|
|
filePathName = arg2;
|
|
go = arg3;
|
|
inp_ModelName.text = fileName;
|
|
btn_ModelFile.GetComponentInChildren<Text>().text = fileName;
|
|
}
|
|
|
|
private void OnClickbtn_Cancel()
|
|
{
|
|
AssetManager.Instance.CancelAsset();
|
|
Close();
|
|
}
|
|
|
|
private void OnClickbtn_Push()
|
|
{
|
|
AssetManager.Instance.AddItemAndGenIcon(fileName, filePathName, assetTag, go);
|
|
CommonHelper.MessageBox("消息", $"{fileName}上传成功", null, null, CommonHelper.MessageBoxType.确定);
|
|
Close();
|
|
}
|
|
|
|
public void SetTag(AssetTag assetTag)
|
|
{
|
|
this.assetTag = assetTag;
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
btn_ModelFile.onClick.RemoveListener(OnClickbtn_ModelFile);
|
|
btn_Push.onClick.RemoveListener(OnClickbtn_Push);
|
|
|
|
btn_ModelFile = null;
|
|
inp_ModelName = null;
|
|
dro_BiaoQian = null;
|
|
dro_LeiXing = null;
|
|
raw_Min = null;
|
|
txt_ScaleX = null;
|
|
txt_ScaleY = null;
|
|
txt_ScaleZ = null;
|
|
inp_BeiZhu = null;
|
|
raw_Max = null;
|
|
btn_Push = null;
|
|
}
|
|
}
|
|
} |