public static void ShowTooltip(string tooltip, PointerEventData pointer, UISkin skin = null, Canvas referenceCanvas = null) { bool hasCanvasChanged = CreatePopupCanvas(referenceCanvas); if (!tooltipPopup) { tooltipPopup = (Tooltip)Object.Instantiate(Resources.Load <Tooltip>("RuntimeInspector/Tooltip"), popupCanvas.transform, false); hasCanvasChanged = true; } else { tooltipPopup.gameObject.SetActive(true); } if (hasCanvasChanged) { tooltipPopup.Initialize(popupCanvas); } if (skin) { tooltipPopup.Skin = skin; } tooltipPopup.SetContent(tooltip, pointer); }
protected virtual void Update() { if (m_skin && m_skinVersion != m_skin.Version) { m_skinVersion = m_skin.Version; RefreshSkin(); #if UNITY_EDITOR prevSkin = m_skin; #endif } }
public static DraggedReferenceItem CreateDraggedReferenceItem(Object reference, PointerEventData draggingPointer, UISkin skin = null, Canvas referenceCanvas = null) { bool hasCanvasChanged = CreatePopupCanvas(referenceCanvas); DraggedReferenceItem referenceItem; if (draggedReferenceItemsPool.Count > 0) { referenceItem = draggedReferenceItemsPool.Pop(); referenceItem.gameObject.SetActive(true); } else { referenceItem = (DraggedReferenceItem)Object.Instantiate(Resources.Load <DraggedReferenceItem>("RuntimeInspector/DraggedReferenceItem"), popupCanvas.transform, false); hasCanvasChanged = true; } if (hasCanvasChanged) { referenceItem.Initialize(popupCanvas); } if (skin) { referenceItem.Skin = skin; } referenceItem.SetContent(reference, draggingPointer); draggingPointer.dragging = true; draggingPointer.eligibleForClick = false; return(referenceItem); }
public void Initialize(Canvas canvas, Object reference, PointerEventData draggingPointer, UISkin skin) { rectTransform = (RectTransform)transform; this.canvas = canvas; canvasTransform = (RectTransform)canvas.transform; m_reference = reference; referenceName.text = reference.GetNameWithType(); pointerId = draggingPointer.pointerId; if (skin != null) { borderLayoutElement.SetHeight(skin.LineHeight * 2.5f); background.GetComponent <LayoutElement>().minHeight = skin.LineHeight; float alpha = background.color.a; Color skinColor = skin.InputFieldNormalBackgroundColor.Tint(0.05f); skinColor.a = alpha; background.color = skinColor; referenceName.SetSkinInputFieldText(skin); } OnDrag(draggingPointer); draggingPointer.pointerDrag = gameObject; draggingPointer.dragging = true; }
public static DraggedReferenceItem CreateDraggedReferenceItem(Object reference, PointerEventData draggingPointer, UISkin skin = null) { DraggedReferenceItem referenceItem = Object.Instantiate(Resources.Load <DraggedReferenceItem>("RuntimeInspector/DraggedReferenceItem"), DraggedReferenceItemsCanvas.transform, false); referenceItem.Initialize(DraggedReferenceItemsCanvas, reference, draggingPointer, skin); return(referenceItem); }
public void Initialize(Canvas canvas, Object reference, PointerEventData draggingPointer, UISkin skin) { rectTransform = (RectTransform)transform; canvasTransform = (RectTransform)canvas.transform; m_reference = reference; referenceName.text = reference.GetNameWithType(); this.draggingPointer = draggingPointer; if (canvas.renderMode == RenderMode.ScreenSpaceOverlay || (canvas.renderMode == RenderMode.ScreenSpaceCamera && canvas.worldCamera == null)) { worldCamera = null; } else { worldCamera = canvas.worldCamera ? canvas.worldCamera : Camera.main; } if (skin != null) { borderLayoutElement.SetHeight(skin.LineHeight * 2.5f); background.GetComponent <LayoutElement>().minHeight = skin.LineHeight; float alpha = background.color.a; Color skinColor = skin.InputFieldNormalBackgroundColor.Tint(0.05f); skinColor.a = alpha; background.color = skinColor; referenceName.SetSkinInputFieldText(skin); } OnDrag(draggingPointer); draggingPointer.pointerDrag = gameObject; draggingPointer.dragging = true; StartCoroutine(ValidatePointer()); }
public static DraggedReferenceItem CreateDraggedReferenceItem(Object reference, PointerEventData draggingPointer, UISkin skin = null) { DraggedReferenceItem dri = GameObject.Find("BTDebugInspector").GetComponent <BTDebugInspector>().draggedReferenceItemPrefab; DraggedReferenceItem referenceItem = (DraggedReferenceItem)Object.Instantiate(dri, DraggedReferenceItemsCanvas.transform, false); referenceItem.Initialize(DraggedReferenceItemsCanvas, reference, draggingPointer, skin); return(referenceItem); }
public static DraggedReferenceItem CreateDraggedReferenceItem(Object[] references, PointerEventData draggingPointer, UISkin skin = null, Canvas referenceCanvas = null) { if (references.IsEmpty()) { return(null); } #if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER // On new Input System, DraggedReferenceItem is tracked by a custom PointerEventData that is tracked by Pointer.current. Make sure that that pointer exists and is pressed if (Pointer.current == null || !Pointer.current.press.isPressed) { return(null); } #endif HideTooltip(); bool hasCanvasChanged = CreatePopupCanvas(referenceCanvas); DraggedReferenceItem referenceItem; if (draggedReferenceItemsPool.Count > 0) { referenceItem = draggedReferenceItemsPool.Pop(); referenceItem.gameObject.SetActive(true); } else { referenceItem = (DraggedReferenceItem)Object.Instantiate(Resources.Load <DraggedReferenceItem>("RuntimeInspector/DraggedReferenceItem"), popupCanvas.transform, false); hasCanvasChanged = true; } if (hasCanvasChanged) { referenceItem.Initialize(popupCanvas); } if (skin) { referenceItem.Skin = skin; } referenceItem.SetContent(references, draggingPointer); draggingPointer.dragging = true; draggingPointer.eligibleForClick = false; return(referenceItem); }
public static DraggedReferenceItem CreateDraggedReferenceItem(Object reference, PointerEventData draggingPointer, UISkin skin = null, Canvas referenceCanvas = null) { return(CreateDraggedReferenceItem(new Object[1] { reference }, draggingPointer, skin, referenceCanvas)); }
public static void SetSkinText(this Text text, UISkin skin) { text.color = skin.TextColor; text.font = skin.Font; text.fontSize = skin.FontSize; }
public static void SetSkinButton(this Button button, UISkin skin) { button.targetGraphic.color = skin.ButtonBackgroundColor; button.GetComponentInChildren <Text>().SetSkinButtonText(skin); }