private IEnumerable <IValueEntity> GetChildrenImpl(IPresentationOptions options, CancellationToken token)
            {
                myGetElementMethod = MetadataTypeLiteEx.LookupInstanceMethodSafe(mySerializedPropertyRole.ReifiedType.MetadataType,
                                                                                 myGetMethodElementSelector, false);
                if (myGetElementMethod == null)
                {
                    myLogger.Warn("Cannot find GetArrayElementAtIndex/GetFixedBufferElementAtIndex method");
                    yield break;
                }

                if (options.ClusterArrays)
                {
                    foreach (var valueEntity in GetChunkedChildren(mySerializedPropertyRole, 0, myArraySize, options, token))
                    {
                        yield return(valueEntity);
                    }
                }
                else
                {
                    for (var i = 0; i < myArraySize; i++)
                    {
                        token.ThrowIfCancellationRequested();
                        yield return(GetElementValueAt(mySerializedPropertyRole, i, options));
                    }
                }
            }
Ejemplo n.º 2
0
            private string GetComponentName(IValueReference <TValue> componentValue,
                                            [CanBeNull] IReifiedType <TValue> objectNamesType,
                                            [CanBeNull] IMetadataMethodLite getInspectorTitleMethod,
                                            IStackFrame frame,
                                            IValueFetchOptions options, IValueServicesFacade <TValue> services)
            {
                if (objectNamesType != null && getInspectorTitleMethod != null)
                {
                    try
                    {
                        var inspectorTitle = objectNamesType.CallStaticMethod(frame, options, getInspectorTitleMethod,
                                                                              componentValue.GetValue(options));
                        var stringValueRole =
                            new SimpleValueReference <TValue>(inspectorTitle, frame, services.RoleFactory)
                            .AsStringSafe(options);
                        if (stringValueRole != null)
                        {
                            return(stringValueRole.GetString());
                        }
                    }
                    catch (Exception e)
                    {
                        myLogger.Error(e, "Unable to fetch object names for {0}", componentValue);
                    }
                }

                return(componentValue.GetPrimaryRole(options).ReifiedType.MetadataType.ShortName);
            }
Ejemplo n.º 3
0
 public GameObjectsGroup(IObjectValueRole <TValue> valueRole, IMetadataMethodLite getRootObjectMethod,
                         IValueServicesFacade <TValue> valueServices)
     : base("Game Objects")
 {
     myValueRole           = valueRole;
     myGetRootObjectMethod = getRootObjectMethod;
     myValueServices       = valueServices;
 }
 public GameObjectsGroup(IObjectValueRole <TValue> sceneValueRole, IMetadataMethodLite getRootObjectsMethod,
                         IValueServicesFacade <TValue> valueServices, ILogger logger)
     : base("Game objects")
 {
     mySceneValueRole       = sceneValueRole;
     myGetRootObjectsMethod = getRootObjectsMethod;
     myValueServices        = valueServices;
     myLogger = logger;
 }
            private IEnumerable <IValueEntity> GetChildrenImpl(IPresentationOptions options, CancellationToken token)
            {
                // The children of a GameObject (as seen in Unity's Hierarchy view) are actually the children of
                // gameObject.transform. This will never be null.
                var transformRole = myGameObjectRole.GetInstancePropertyReference("transform")?.AsObjectSafe(options);

                if (transformRole == null)
                {
                    myLogger.Warn("Unable to retrieve GameObject.transform");
                    yield break;
                }

                var childCount = transformRole.GetInstancePropertyReference("childCount", true)
                                 ?.AsPrimitiveSafe(options)?.GetPrimitiveSafe <int>() ?? 0;

                if (childCount == 0)
                {
                    myLogger.Trace("No child transform, or unable to fetch childCount");
                    yield break;
                }

                var transformType = transformRole.ReifiedType.MetadataType.FindTypeThroughHierarchy("UnityEngine.Transform");

                myGetChildMethod = transformType?.GetMethods().FirstOrDefault(ourGetChildSelector);
                if (myGetChildMethod == null)
                {
                    myLogger.Warn("Unable to find Transform.GetChild method");
                    yield break;
                }

                if (options.ClusterArrays)
                {
                    foreach (var valueEntity in GetChunkedChildren(transformRole, 0, childCount, options, token))
                    {
                        yield return(valueEntity);
                    }
                }
                else
                {
                    for (var i = 0; i < childCount; i++)
                    {
                        yield return(GetElementValueAt(transformRole, i, options));
                    }
                }
            }
            private bool TryInvokeNext(IObjectValueRole <TValue> serializedPropertyRole,
                                       IMetadataMethodLite nextMethod,
                                       TValue boolArg,
                                       IValueFetchOptions options,
                                       out bool returnValue)
            {
                returnValue = false;

                var returnValueRole = new SimpleValueReference <TValue>(
                    serializedPropertyRole.CallInstanceMethod(nextMethod, boolArg),
                    mySerializedPropertyRole.ValueReference.OriginatingFrame,
                    myValueServices.RoleFactory)
                                      .AsPrimitiveSafe(options);

                if (returnValueRole == null)
                {
                    myLogger.Warn("Unable to call Next on serializedProperty");
                    return(false);
                }

                returnValue = returnValueRole.GetPrimitive <bool>();
                return(true);
            }
Ejemplo n.º 7
0
            private string GetComponentName(IValueReference <TValue> componentValue,
                                            [CanBeNull] IReifiedType <TValue> objectNamesType,
                                            [CanBeNull] IMetadataMethodLite getInspectorTitleMethod,
                                            IStackFrame frame,
                                            IValueFetchOptions options,
                                            IValueServicesFacade <TValue> services,
                                            out bool isNameFromValue)
            {
                if (objectNamesType != null && getInspectorTitleMethod != null)
                {
                    try
                    {
                        var inspectorTitle = objectNamesType.CallStaticMethod(frame, options, getInspectorTitleMethod,
                                                                              componentValue.GetValue(options));
                        var stringValueRole =
                            new SimpleValueReference <TValue>(inspectorTitle, frame, services.RoleFactory)
                            .AsStringSafe(options);
                        if (stringValueRole != null)
                        {
                            isNameFromValue = true;
                            return(stringValueRole.GetString());
                        }
                    }
                    catch (EvaluatorAbortedException e)
                    {
                        myLogger.LogExceptionSilently(e);
                    }
                    catch (Exception e)
                    {
                        myLogger.Warn(e, ExceptionOrigin.Algorithmic,
                                      $"Unable to fetch object names for {componentValue}");
                    }
                }

                isNameFromValue = false;
                return(componentValue.GetPrimaryRole(options).ReifiedType.MetadataType.ShortName);
            }