Forge/Integration/DataRegistry.cs
/// <summary>
/// Adds the registered data renderer for the given data type to the given context
/// GameObject. If there is no registered data renderer, then this method does not modify
/// the context.
/// </summary>
/// <param name="dataType">The type of data to add a renderer for.</param>
/// <param name="context">The object to add the renderer to.</param>
/// <param name="entity">The entity that the renderer will operate on.</param>
/// <returns></returns>
Adds the registered data renderer for the given data type to the given context
GameObject. If there is no registered data renderer, then this method does not modify
the context.
Adds the registered data renderer for the given data type to the given context GameObject . If there is no registered data renderer then this method does not modify the context .
public static Maybe<DataRenderer> TryAddRenderer(DataAccessor dataType, GameObject context,
            IQueryableEntity entity) {
            int id = dataType.Id;
            if (_renderers.ContainsKey(id)) {
                Type rendererType = _renderers[id];
                if (context.GetComponent(rendererType) == null) {
                    DataRenderer renderer = (DataRenderer)context.AddComponent(rendererType);
                    renderer.Initialize(entity);
                    return Maybe.Just(renderer);
                }
            }
            return Maybe<DataRenderer>.Empty;
        }
public static Maybe < DataRenderer > TryAddRenderer ( DataAccessor dataType , GameObject context , IQueryableEntity entity ) { int id = dataType . Id ; if ( _renderers . ContainsKey ( id ) ) { Type rendererType = _renderers [ id ] ; if ( context . GetComponent ( rendererType ) == null ) { DataRenderer renderer = ( DataRenderer ) context . AddComponent ( rendererType ) ; renderer . Initialize ( entity ) ; return Maybe . Just ( renderer ) ; } } return Maybe < DataRenderer > . Empty ; }
Adds the registered data renderer for the given data type to the given context
GameObject.
Adds the registered data renderer for the given data type to the given context GameObject .
// only add the renderer if we don't have one already
None
dataType
DataAccessor
The type of data to add a renderer for.
The type of data to add a renderer for .
context
GameObject
The object to add the renderer to.
The object to add the renderer to .
entity
IQueryableEntity
The entity that the renderer will operate on.
The entity that the renderer will operate on .