/// <summary> /// This method changes the rendering method used for this group. You must provide the type /// of the rendering method to switch to, as well as if features should be added to match /// the existing feature data objects present in the graphics that are attached. /// /// This is an editor only method, as rendering types cannot be changed at runtime! /// </summary> public void ChangeRenderingMethod(Type renderingMethodType, bool addFeatures) { AssertHelper.AssertEditorOnly(); Assert.IsNotNull(renderingMethodType); if (_group._renderingMethod.Value != null) { _group._renderingMethod.Value.OnDisableRendererEditor(); _group._renderingMethod.Value = null; } _group._renderingMethod.Value = Activator.CreateInstance(renderingMethodType) as LeapRenderingMethod; Assert.IsNotNull(_group._renderingMethod.Value); ILeapInternalRenderingMethod renderingMethodInternal = _group._renderingMethod.Value; renderingMethodInternal.renderer = _group._renderer; renderingMethodInternal.group = _group; if (addFeatures) { List <Type> dataObjTypes = new List <Type>(); var allGraphics = _group.renderer.GetComponentsInChildren <LeapGraphic>(); foreach (var graphic in allGraphics) { if (_group._renderingMethod.Value.IsValidGraphic(graphic)) { List <Type> types = new List <Type>(); for (int i = 0; i < graphic.featureData.Count; i++) { var dataObj = graphic.featureData[i]; var dataType = dataObj.GetType(); if (!dataObjTypes.Contains(dataType)) { types.Add(dataType); } } foreach (var type in types) { if (dataObjTypes.Query().Count(t => t == type) < types.Query().Count(t => t == type)) { dataObjTypes.Add(type); } } } } foreach (var type in dataObjTypes) { var featureType = LeapFeatureData.GetFeatureType(type); if (featureType != null) { AddFeature(featureType); } } } _group._renderingMethod.Value.OnEnableRendererEditor(); OnValidate(); }
public override void AddFeatureData(LeapFeatureData data) { this.featureData.Add(data as DataType); }
/// <summary> /// Returns whether or not a feature data object is a valid object /// that can be used to drive texture data for this panel. Only /// a TextureData object or a SpriteData object are currently valid. /// </summary> public static bool IsValidDataSource(LeapFeatureData dataSource) { return(dataSource is LeapTextureData || dataSource is LeapSpriteData); }
public abstract void AddFeatureData(LeapFeatureData data);