public void SetCursor(CursorType cursorType) { if (DragItem.isDragging) { return; } if (currentCursor == cursorType) { return; } string cursorName = null; if (cursorNameDict.TryGetValue(cursorType, out cursorName)) { if (UIAtlasManager.GetInstance().HasSprite(ResourceAtlasName, cursorName)) { currentCursor = cursorType; cursor.spriteName = cursorNameDict[cursorType]; } } else { cursorType = CursorType.ctNormal; cursor.spriteName = cursorNameDict[CursorType.ctNormal]; } cursor.layer = 1000000; cursor.MakePixelPerfect(); }
public static UIAtlasManager GetInstance() { if (instance == null) { instance = new UIAtlasManager(); } return(instance); }
public static UISprite AddUISprite(GameObject parentGo, string resourceName, string imageName) { GameObject go = new GameObject("UISprite"); go.transform.parent = parentGo.transform; UISprite sprite = go.AddComponent <UISprite>(); float s = 0.002857143f * 20f; go.transform.localScale = new Vector3(s, s, s); go.transform.localPosition = Vector3.zero; sprite.atlas = UIAtlasManager.GetInstance().GetUIAtlas(resourceName); sprite.spriteName = imageName; return(sprite); }
void Awake() { GameObject cursorLayer = LayerManager.GetInstance().CursorLayer; GameObject go = new GameObject("cursor"); GameObject.DontDestroyOnLoad(go); go.hideFlags = HideFlags.DontSave; go.transform.parent = cursorLayer.transform; obj = go; cursor = go.AddComponent <UISprite>(); cursor.layer = int.MaxValue; cursor.atlas = UIAtlasManager.GetInstance().GetUIAtlas(ResourceAtlasName); cursor.pivot = UIWidget.Pivot.TopLeft; ObjectUtil.SetLayerWithAllChildren(cursor.gameObject, "2D"); mTrans = go.transform; RegisterCursor(); SetCursor(CursorType.ctNormal); LayerManager.ResetDepth(cursorLayer); uiCamera = ViewCameraManager.GetInstance().UICamera; }
public void ClearDragCursor() { drawType = DrawDataType.NONE; cursor.atlas = UIAtlasManager.GetInstance().GetUIAtlas(ResourceAtlasName); cursor.spriteName = cursorNameDict[currentCursor]; }