This commit is contained in:
2025-11-26 21:34:22 +08:00
parent a2dc1f199a
commit be99a8ce1d
606 changed files with 8256 additions and 2685 deletions

View File

@@ -4,30 +4,19 @@ namespace StudyCase3
{
public class Item : MonoBehaviour
{
public bool pick;
Outline outline;
bool pick;
ThirdCharacterController player;
private void Awake()
{
player = FindAnyObjectByType<ThirdCharacterController>();
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.OutlineMode = Outline.Mode.OutlineVisible;
outline.OutlineColor = new Color(0, 1, 1);
outline.OutlineWidth = 10f;
gameObject.layer = LayerMask.NameToLayer("Item");
}
@@ -41,5 +30,29 @@ namespace StudyCase3
if (!pick)
outline.enabled = false;
}
public void PickUp(Transform root)
{
if (pick) return;
pick = true;
transform.SetParent(root);
outline.OutlineWidth = 2f;
gameObject.layer = LayerMask.NameToLayer("Default");
player.SetItems();
}
private void OnMouseEnter()
{
if (player.pickMode == PickMode.Mouse)
Select();
}
private void OnMouseExit()
{
if (player.pickMode == PickMode.Mouse)
UnSelect();
}
private void OnMouseDown()
{
if (player.pickMode == PickMode.Mouse)
PickUp(player.itemRoot);
}
}
}