private IValueReference <TValue> GetThisGameObjectForMonoBehaviour(IStackFrame frame) { try { var thisObj = frame.GetThis(mySession.EvaluationOptions); if (thisObj?.DeclaredType?.FindTypeThroughHierarchy("UnityEngine.MonoBehaviour") != null) { if (!(thisObj.GetPrimaryRole(mySession.EvaluationOptions) is IObjectValueRole <TValue> role)) { myLogger.Warn("Unable to get 'this' as object value"); return(null); } var gameObjectReference = role.GetInstancePropertyReference("gameObject", true); if (gameObjectReference == null) { myLogger.Warn("Unable to get 'this.gameObject' as a property reference"); return(null); } var gameObject = gameObjectReference.GetValue(mySession.EvaluationOptions); var gameObjectType = gameObjectReference.GetValueType(mySession.EvaluationOptions, myValueServices.ValueMetadataProvider); // Don't show type for each child game object. It's always "GameObject", and we know they're game // objects from the synthetic group. return(new SimpleValueReference <TValue>(gameObject, gameObjectType, "this.gameObject", ValueOriginKind.Property, ValueFlags.None | ValueFlags.IsDefaultTypePresentation | ValueFlags.IsReadOnly, frame, myValueServices.RoleFactory)); } } catch (Exception ex) { myLogger.LogException(ex); } return(null); }