UI相关逻辑
This commit is contained in:
parent
827332bcaa
commit
7506bda817
4168
xiaofang/Assets/Prefabs/HYLPrefabs/Panel/FreePanel05 1.prefab
Normal file
4168
xiaofang/Assets/Prefabs/HYLPrefabs/Panel/FreePanel05 1.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6bc22e68f9bdf24e964187685be82d9
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3984
xiaofang/Assets/Prefabs/HYLPrefabs/Panel/FreePanel07.prefab
Normal file
3984
xiaofang/Assets/Prefabs/HYLPrefabs/Panel/FreePanel07.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdccec4dc57086b43abe885a5242e27f
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -109,6 +109,7 @@ GameObject:
|
||||
- component: {fileID: 557942137187336893}
|
||||
- component: {fileID: 6218000086705861260}
|
||||
- component: {fileID: 6335157935193920567}
|
||||
- component: {fileID: 2781362794876327239}
|
||||
m_Layer: 5
|
||||
m_Name: Task
|
||||
m_TagString: Untagged
|
||||
@ -230,3 +231,47 @@ MonoBehaviour:
|
||||
jr: {fileID: 0}
|
||||
id: 0
|
||||
tasktxt: {fileID: 3645880154395566472}
|
||||
--- !u!114 &2781362794876327239
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3645880154619645306}
|
||||
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: 3645880154619645284}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -5,18 +6,27 @@ using UnityEngine.UI;
|
||||
|
||||
public class TaskItem : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
public JSONReader jr;
|
||||
|
||||
public int id;
|
||||
|
||||
public Text tasktxt;
|
||||
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnClickButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void SetInfo(int id,JSONReader js)
|
||||
{
|
||||
this.id = id;
|
||||
|
@ -31,7 +31,9 @@ public class TaskPanel : Base
|
||||
public float hidePositionX = 125f; // 隐藏到右边的 X 坐标值,具体值根据屏幕大小调整
|
||||
public float showPositionX = -198f; // 显示时按钮的 X 坐标值
|
||||
|
||||
|
||||
public List<Button> buttons; // 所有的任务
|
||||
public Color selectedColor = new Color(0.5f, 0.5f, 1f, 1f); // 紫色
|
||||
public Color defaultColor = Color.white; // 白色
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@ -62,7 +64,7 @@ public class TaskPanel : Base
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//实例化任务
|
||||
public async void InitTask()
|
||||
{
|
||||
await DestroyTaskAsync();
|
||||
@ -72,6 +74,29 @@ public class TaskPanel : Base
|
||||
go.transform.name = "Task_" + i;
|
||||
TaskItem item = go.GetComponent<TaskItem>();
|
||||
item.SetInfo(taskId[i], JSONReader);
|
||||
Button button = go.GetComponent<Button>();
|
||||
button.onClick.AddListener(() => OnButtonClicked(button));
|
||||
buttons.Add(button);
|
||||
}
|
||||
}
|
||||
|
||||
// 当点击任务时触发选中
|
||||
void OnButtonClicked(Button clickedButton)
|
||||
{
|
||||
// 遍历所有按钮并重置颜色
|
||||
foreach (Button button in buttons)
|
||||
{
|
||||
Image buttonImage = button.GetComponent<Image>();
|
||||
if (button == clickedButton)
|
||||
{
|
||||
// 设置被点击按钮的颜色为紫色
|
||||
buttonImage.color = selectedColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 重置其他按钮为白色
|
||||
buttonImage.color = defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,6 +112,8 @@ public class TaskPanel : Base
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
//清除按钮
|
||||
buttons.Clear();
|
||||
}
|
||||
|
||||
public void SetInfo(int id)
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -5,12 +5,14 @@ using UnityEngine.UI;
|
||||
|
||||
public class task : MonoBehaviour
|
||||
{
|
||||
private Text taskte;
|
||||
private Text taskte;
|
||||
private float timer = 0;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
taskte = this.GetComponent<Text>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +29,10 @@ public class task : MonoBehaviour
|
||||
//Debug.Log(taskte.text);
|
||||
}
|
||||
|
||||
public void SetInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user