using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; using Wing.Utils; namespace Wing.Gizmos { public class GizmosManager : MonoSingleton { private GizmosMove _gizmosMove; private GizmosScale _gizmosScale; private GizmosRotate _gizmosRotate; void Start() { var glayer = 1 << LayerMask.NameToLayer(Settings.GizmosLayerName); var nlayer = 1 << LayerMask.NameToLayer(Settings.NavLayerName); var mask = Camera.main.cullingMask; Camera.main.cullingMask = ((glayer | mask) & ~nlayer); } public static bool IsOnGizmos() { int layer = LayerMask.NameToLayer(Settings.GizmosLayerName); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000, 1 << layer)) { return hit.collider.gameObject != null; } return false; } public GizmosRotate GetSingleRotate() { if(_gizmosRotate == null) { _gizmosRotate = CreateRotate(); } return _gizmosRotate; } public GizmosRotate CreateRotate() { GameObject go = new GameObject("gizmos-rotate"); go.transform.SetParent(this.transform); return go.AddComponent(); } public GizmosMove GetSingleMove() { if(_gizmosMove == null) { _gizmosMove = CreateMove(); } return _gizmosMove; } public GizmosMove CreateMove() { GameObject Prefab = Resources.Load("Prefabs/GizmosMove") as GameObject; GameObject obj = Instantiate(Prefab); return obj.GetComponent(); } public GizmosScale GetSingleScale() { if(_gizmosScale == null) { _gizmosScale = CreateScale(); } return _gizmosScale; } public GizmosScale CreateScale() { GameObject Prefab = Resources.Load("Prefabs/GizmosScale") as GameObject; GameObject obj = Instantiate(Prefab); return obj.GetComponent(); } } }