/*--------------------------------------------------------------------------------------------*/ private void BuildCursor(HoverCursorDataProvider pProv, ICursorData pData) { var curGo = new GameObject(pData.Type + ""); curGo.transform.SetParent(gameObject.transform, false); TreeUpdater treeUp = curGo.AddComponent <TreeUpdater>(); HoverCursorFollower follow = curGo.AddComponent <HoverCursorFollower>(); follow.CursorDataProvider = pProv; follow.CursorType = pData.Type; follow.FollowCursorActive = false; follow.ScaleUsingCursorSize = true; HoverCursorRendererUpdater cursRendUp = curGo.AddComponent <HoverCursorRendererUpdater>(); cursRendUp.CursorRendererPrefab = CursorRendererPrefab; if (pData.Idle != null) { HoverIdleRendererUpdater idleRendUp = curGo.AddComponent <HoverIdleRendererUpdater>(); idleRendUp.IdleRendererPrefab = IdleRendererPrefab; } follow.Update(); //moves interface to the correct cursor transform treeUp.UpdateAtAndBelowThisLevel(); //force renderer creation }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void Awake() { if (CursorDataProvider == null) { CursorDataProvider = FindObjectOfType <HoverCursorDataProvider>(); } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public static bool FindCursorReference(MonoBehaviour pModule, ref HoverCursorDataProvider pProv, bool pShowLog) { if (pProv != null) { return(true); } pProv = HoverCursorDataProvider.Instance; if (pShowLog) { string typeName = typeof(HoverCursorDataProvider).Name; if (pProv == null) { Debug.LogWarning("Could not find '" + typeName + "' reference.", pModule); } else { Debug.Log("Found '" + typeName + "' reference.", pModule); } } return(pProv != null); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void Awake() { if (CursorDataProvider == null) { CursorDataProvider = HoverCursorDataProvider.Instance; } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void PerformBuild() { HoverCursorDataProvider cursorProv = HoverCursorDataProvider.Instance; foreach (ICursorData cursorData in cursorProv.Cursors) { if (cursorData.Capability < MinimumCapabilityType) { continue; } BuildCursor(cursorProv, cursorData); } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void PerformBuild() { HoverCursorDataProvider cursorProv = FindObjectOfType <HoverCursorDataProvider>(); foreach (ICursorData cursorData in cursorProv.Cursors) { if (cursorData.Capability < MinimumCapabilityType) { continue; } BuildCursor(cursorProv, cursorData); } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void UpdateData(HoverCursorDataProvider pCursorDataProv) { if (!pCursorDataProv.HasCursorData(Type)) { return; } ICursorDataForInput data = pCursorDataProv.GetCursorDataForInput(Type); if (data == null) { return; } if (FollowTransform == null) { data.SetUsedByInput(false); return; } data.SetUsedByInput(FollowTransform.gameObject.activeInHierarchy); data.SetWorldPosition(FollowTransform.position); data.SetWorldRotation(FollowTransform.rotation); }