This commit is contained in:
2025-11-25 17:41:28 +08:00
parent 173fe7574b
commit a2dc1f199a
20 changed files with 4559 additions and 4199 deletions

View File

@@ -0,0 +1,45 @@
using UnityEngine;
namespace StudyCase3
{
public class Item : MonoBehaviour
{
public bool pick;
Outline outline;
private void Awake()
{
if (outline == null)
outline = gameObject.AddComponent<Outline>();
else
outline = GetComponent<Outline>();
outline.OutlineMode = Outline.Mode.OutlineVisible;
outline.OutlineColor = new Color(0,1,1);
outline.OutlineWidth = 10f;
outline.enabled = false;
gameObject.layer = LayerMask.NameToLayer("Item");
}
public void PickUp(Transform root)
{
pick = true;
outline.OutlineWidth = 2f;
gameObject.layer = LayerMask.NameToLayer("Default");
transform.SetParent(root);
}
public void UnPickUp()
{
pick = false;
outline.OutlineWidth = 10f;
gameObject.layer = LayerMask.NameToLayer("Item");
}
public void Select()
{
if(!pick)
outline.enabled = true;
}
public void UnSelect()
{
if (!pick)
outline.enabled = false;
}
}
}