case3
This commit is contained in:
45
Assets/Scripts/StudyCase3/Item.cs
Normal file
45
Assets/Scripts/StudyCase3/Item.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user