道具栏增加悬停功能
This commit is contained in:
parent
e6c4b795f5
commit
2c23d0d41c
@ -280,7 +280,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastTarget: 0
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
@ -502,6 +502,7 @@ GameObject:
|
||||
- component: {fileID: 323542383032252423}
|
||||
- component: {fileID: 6025220162707536696}
|
||||
- component: {fileID: 3617749440597198166}
|
||||
- component: {fileID: 5740481659040249477}
|
||||
m_Layer: 0
|
||||
m_Name: ItemPrefab
|
||||
m_TagString: Untagged
|
||||
@ -626,9 +627,23 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
MarkType: 0
|
||||
CustomComponentName:
|
||||
CustomComponentName: ItemPrefab
|
||||
CustomComment:
|
||||
mComponentName: UnityEngine.UI.Button
|
||||
--- !u!114 &5740481659040249477
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1901611519389403572}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 456e447344348cf4680f6e09405e7b79, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
objs:
|
||||
- {fileID: 5478117157784657024}
|
||||
--- !u!1 &2685508885550636136
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
37
Assets/Scripts/Item/MouseOverItem.cs
Normal file
37
Assets/Scripts/Item/MouseOverItem.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class MouseOverItem : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
public List<GameObject> objs;
|
||||
private void Awake()
|
||||
{
|
||||
SetItem(false);
|
||||
}
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
|
||||
SetItem(true);
|
||||
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
|
||||
SetItem(false);
|
||||
|
||||
}
|
||||
|
||||
public void SetItem(bool isActive)
|
||||
{
|
||||
if (objs != null)
|
||||
{
|
||||
foreach (var obj in objs)
|
||||
{
|
||||
obj.SetActive(isActive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Item/MouseOverItem.cs.meta
Normal file
11
Assets/Scripts/Item/MouseOverItem.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 456e447344348cf4680f6e09405e7b79
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -64,7 +64,6 @@ namespace QFramework.Example
|
||||
GameObject right = icon.transform.Find("Right").gameObject;
|
||||
GameObject wrong = icon.transform.Find("Wrong").gameObject;
|
||||
GameObject Selected = icon.transform.Find("Selected").gameObject;
|
||||
GameObject CurSelect = obj.transform.Find("CurSelect").gameObject;
|
||||
mResLoader.Add2Load(localImageUrl.ToNetImageResName(),
|
||||
(bool success, IRes res) =>
|
||||
{
|
||||
@ -76,7 +75,6 @@ namespace QFramework.Example
|
||||
Button btn = obj.GetComponent<Button>();
|
||||
btn.onClick.AddListener(() =>
|
||||
{
|
||||
CurSelect.gameObject.SetActive(true);
|
||||
if (answers != null)
|
||||
{
|
||||
if (answers.Contains(item.Name))
|
||||
@ -128,8 +126,6 @@ namespace QFramework.Example
|
||||
GameObject right = icon.Find("Right").gameObject;
|
||||
GameObject wrong = icon.Find("Wrong").gameObject;
|
||||
GameObject Selected = icon.Find("Selected").gameObject;
|
||||
GameObject CurSelect = item.transform.Find("CurSelect").gameObject;
|
||||
CurSelect.SetActive(false);
|
||||
Selected.SetActive(true);
|
||||
if (isRight)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user