139 lines
5.3 KiB
C#
139 lines
5.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
using Toolset.UI;
|
|
using DG.Tweening;
|
|
|
|
/// <summary>
|
|
/// 二级菜单管理
|
|
/// </summary>
|
|
public class Menuitem : MonoBehaviour,IPointerClickHandler
|
|
{
|
|
public BaseConf conf_child;//子菜单配置文件
|
|
|
|
public Text text_cn;//药材名
|
|
public Text text_lt;//拉丁名
|
|
public Text text_title;//标题
|
|
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
CarouselMenu carouselMenu = UI_manage.inst.Grid.GetComponent<CarouselMenu>();
|
|
carouselMenu.OnPointerClick(eventData);//点击二级菜单转动
|
|
|
|
if (!UI_manage.inst.IsShow_synopsis)
|
|
{
|
|
AudioSource a = Camera.main.GetComponent<AudioSource>();
|
|
a.clip = Resources.Load<AudioClip>("纸卷轴8");
|
|
a.Play();
|
|
}
|
|
|
|
UI_manage.inst.conf_child = this.conf_child;//赋值:记录当前药材配置文件
|
|
UI_manage.inst.synopsis_parent.SetActive(true);//显示简介父类
|
|
if (!UI_manage.inst.IsShow_synopsis) UI_manage.inst.Synopsis_bt_onClick(false);//如果卷轴关闭则展开
|
|
if (UI_manage.inst.FBX_obj.transform.childCount!=0)
|
|
{
|
|
DestroyImmediate(UI_manage.inst.FBX_obj.transform.GetChild(0).gameObject);
|
|
}
|
|
UI_manage.inst.show3D.gameObject.SetActive(true);
|
|
text_title.gameObject.SetActive(true);
|
|
text_cn.gameObject.SetActive(true);
|
|
text_lt.gameObject.SetActive(true);
|
|
UI_manage.inst.text_synopsis.gameObject.SetActive(true);
|
|
UI_manage.inst.Image_show.gameObject.SetActive(true);
|
|
|
|
GameObject go= Instantiate(conf_child.go, UI_manage.inst.FBX_obj.transform);//实例化药材模型
|
|
UI_manage.inst.FBX_pos = go.transform.localPosition;
|
|
//go.transform.localPosition = conf_child.go.transform.localPosition;
|
|
//go.AddComponent<TouchScreen>();
|
|
UI_manage.inst.FBX_obj.SetActive(false);
|
|
|
|
UI_manage.inst.IsShow_synopsis = true;
|
|
|
|
text_cn.text = conf_child.name_CN;
|
|
text_lt.text = conf_child.name_LT;
|
|
UI_manage.inst.text_synopsis.text = conf_child.synopsis;
|
|
Transform t = UI_manage.inst.text_synopsis.transform.parent;
|
|
t.localPosition = new Vector3(t.localRotation.x, 0, 0);//保持简介内容置顶
|
|
UI_manage.inst.synopsis_bt.interactable = true;
|
|
UI_manage.inst.Image_show.overrideSprite = conf_child.go_img[0];
|
|
UI_manage.inst.Image_show.SetNativeSize();
|
|
|
|
UI_manage.inst.IsShow3D = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击上下按钮切换显示信息并记录当前药材配置文件
|
|
/// </summary>
|
|
/// <param name="conf_child"></param>
|
|
public void OnPointerClick(BaseConf conf_child)
|
|
{
|
|
|
|
UI_manage.inst.conf_child = conf_child;//赋值:记录当前药材配置文件
|
|
//UI_manage.inst.synopsis_parent.SetActive(true);//显示简介父类
|
|
if (!UI_manage.inst.IsShow_synopsis) UI_manage.inst.Synopsis_bt_onClick(UI_manage.inst.IsShow_synopsis);//如果卷轴关闭则展开
|
|
if (UI_manage.inst.FBX_obj.transform.childCount != 0)
|
|
{
|
|
Destroy(UI_manage.inst.FBX_obj.transform.GetChild(0).gameObject);
|
|
}
|
|
UI_manage.inst.show3D.gameObject.SetActive(true);
|
|
if (UI_manage.inst.synopsis_parent.activeSelf)
|
|
{
|
|
text_title.gameObject.SetActive(true);
|
|
UI_manage.inst.text_synopsis.gameObject.SetActive(true);
|
|
}
|
|
text_cn.gameObject.SetActive(true);
|
|
text_lt.gameObject.SetActive(true);
|
|
UI_manage.inst.Image_show.gameObject.SetActive(true);
|
|
|
|
GameObject go = Instantiate(conf_child.go, UI_manage.inst.FBX_obj.transform);//实例化药材模型
|
|
UI_manage.inst.FBX_pos = go.transform.localPosition;
|
|
//go.transform.localPosition = conf_child.go.transform.localPosition;
|
|
//go.AddComponent<TouchScreen>();
|
|
UI_manage.inst.FBX_obj.SetActive(false);
|
|
|
|
//UI_manage.inst.IsShow_synopsis = true;
|
|
|
|
text_cn.text = conf_child.name_CN;
|
|
text_lt.text = conf_child.name_LT;
|
|
UI_manage.inst.text_synopsis.text = conf_child.synopsis;
|
|
Transform t = UI_manage.inst.text_synopsis.transform.parent;
|
|
t.localPosition = new Vector3(t.localRotation.x, 0, 0);//保持简介内容置顶
|
|
UI_manage.inst.synopsis_bt.interactable = true;
|
|
UI_manage.inst.Image_show.overrideSprite = conf_child.go_img[0];
|
|
UI_manage.inst.Image_show.SetNativeSize();
|
|
|
|
UI_manage.inst.IsShow3D = false;
|
|
//UI_manage.inst.IsShow_synopsis = UI_manage.inst.synopsis_parent.activeSelf;
|
|
|
|
}
|
|
private void Awake()
|
|
{
|
|
UI_manage.inst.show3D.gameObject.SetActive(false);
|
|
UI_manage.inst.exe_off_img_parent.SetActive(false);
|
|
UI_manage.inst.FBX_obj.SetActive(false);
|
|
text_title.gameObject.SetActive(true);
|
|
text_cn.gameObject.SetActive(true);
|
|
text_lt.gameObject.SetActive(true);
|
|
UI_manage.inst.text_synopsis.gameObject.SetActive(false);
|
|
//UI_manage.inst.Image_show.gameObject.SetActive(false);
|
|
//exe_off_img.gameObject.SetActive(true);
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|