/// <summary> /// <see cref="Close"/> /// </summary> private void _Close() { if (!ReferenceEquals(this.currentContent, null)) { this.currentContent.gameObject.SetActive(false); this.currentContent = null; } }
/// <summary> /// <see cref="Open{T}(T, TooltipAnchorTarget)"/> /// </summary> private void _Open <T>(T model, TooltipAnchorTarget anchor) where T : TooltipViewModel { _Close(); if (!ReferenceEquals(this.currentContent, null)) { this.currentContent.gameObject.SetActive(false); } currentContent = GetContentPrefabInstance(model.prefab); currentContent.gameObject.SetActive(true); currentContent.target = model; currentContent.UpdateBinding(); this.anchor = anchor; UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(this.transform as RectTransform); }
/// <summary> /// Gets a content prefab instance. /// This instance is either already existing (<see cref="contentPrefabInstances"/>) or created and added to the instance dictionary. /// </summary> private DataBindingScriptedRoot GetContentPrefabInstance(DataBindingScriptedRoot prefab) { DataBindingScriptedRoot instance; if (!this.contentPrefabInstances.TryGetValue(prefab, out instance)) { // Validate var go = Instantiate(prefab.gameObject); go.transform.SetParent(this.contentAnchor, false); go.SetActive(false); instance = go.GetComponent <DataBindingScriptedRoot>(); this.contentPrefabInstances.Add(prefab, instance); } return(instance); }