/// <summary> /// Restore the color of the touchable object that just leaves the picker. /// </summary> /// <param name="touchable">Touchable object whose color will be restored.</param> private void RestoreTouchableObjectColorUponExit(ITouchable touchable) { // Equals is overridden by MonoBehaviour, so can be used to check if the game object // has been destroyed. if (touchable == null || touchable.Equals(null)) { return; } Transform touchableTransform = touchable.BindedGameObject.transform; Renderer renderer = touchableTransform.GetComponent <Renderer>(); if (renderer != null && _rendererToRefCountDict.ContainsKey(renderer)) { RestoreRendererColor(renderer); } // Restore color for the renderers of the touchable and its children. foreach (Transform child in touchableTransform) { renderer = child.GetComponent <Renderer>(); if (renderer == null) { continue; } if (!_rendererToRefCountDict.ContainsKey(renderer)) { continue; } RestoreRendererColor(renderer); } }
/// <summary> /// Change the color of the touchable object that first comes into contact with /// the picker. /// </summary> /// <param name="touchable">The touchable that first comes into contact.</param> private void ChangeTouchableObjectColorUponEnter(ITouchable touchable) { if (touchable == null || touchable.Equals(null)) { // Touchable may have been destroyed return; } Transform touchableTransform = touchable.BindedGameObject.transform; Renderer renderer = touchableTransform.GetComponent <Renderer>(); // Change color for all renderers of the object and its children. if (renderer != null) { ChangeRendererColor(renderer, touchable.IndicatedColorOnTouching); } foreach (Transform child in touchableTransform) { renderer = child.GetComponent <Renderer>(); if (renderer == null) { continue; } ChangeRendererColor(renderer, touchable.IndicatedColorOnTouching); } }