using UnityEngine; namespace StudyCase3 { public class Item : MonoBehaviour { public bool pick; Outline outline; private void Awake() { if (outline == null) outline = gameObject.AddComponent(); else outline = GetComponent(); 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; } } }