Exemplo n.º 1
0
        public virtual void GetSupportInfo(List <LeapSpriteFeature> features, List <SupportInfo> info)
        {
            SupportUtil.OnlySupportFirstFeature <LeapSpriteFeature>(info);

#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                Packer.RebuildAtlasCacheIfNeeded(EditorUserBuildSettings.activeBuildTarget);
            }

            for (int i = 0; i < features.Count; i++)
            {
                var feature = features[i];

                if (!feature.AreAllSpritesPacked())
                {
                    info[i] = SupportInfo.Error("Not all sprites are packed.");
                }

                if (!feature.AreAllSpritesOnSameTexture())
                {
                    info[i] = SupportInfo.Error("Not all sprites are packed into same atlas.");
                }
            }
#endif

            for (int i = 0; i < features.Count; i++)
            {
                var feature = features[i];
                if (group.features.Query().OfType <LeapTextureFeature>().Any(s => s.channel == feature.channel))
                {
                    info[i] = info[i].OrWorse(SupportInfo.Error("Sprite features cannot currently share uvs with texture features."));
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Helper method to only support the first element in a list.
 /// </summary>
 public static void OnlySupportFirstFeature <T>(List <SupportInfo> info)
 {
     for (int i = 1; i < info.Count; i++)
     {
         info[i] = SupportInfo.Error("Only the first " + LeapGraphicTagAttribute.GetTagName(typeof(T)) + " is supported.");
     }
 }
Exemplo n.º 3
0
 public override SupportInfo GetSupportInfo(LeapGraphicGroup group)
 {
     if (!group.renderingMethod.IsValidGraphic <LeapMeshGraphicBase>())
     {
         return(SupportInfo.Error("Blend shapes require a renderer that supports mesh graphics."));
     }
     else
     {
         return(SupportInfo.FullSupport());
     }
 }
Exemplo n.º 4
0
 public virtual void GetSupportInfo(List <LeapTextureFeature> features, List <SupportInfo> info)
 {
     for (int i = 0; i < features.Count; i++)
     {
         var feature = features[i];
         if (group.features.Query().OfType <LeapSpriteFeature>().Any(s => s.channel == feature.channel))
         {
             info[i] = info[i].OrWorse(SupportInfo.Error("Texture features cannot currently share uvs with sprite features."));
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Helper method that returns either the current support info struct, or the argument
 /// support info struct.  The argument is only chosen as the return value if it has
 /// less support than the current support.
 /// </summary>
 public SupportInfo OrWorse(SupportInfo other)
 {
     if (other.support > support)
     {
         return(other);
     }
     else
     {
         return(this);
     }
 }
Exemplo n.º 6
0
 public override SupportInfo GetSpaceSupportInfo(LeapSpace space)
 {
     if (space == null ||
         space is LeapCylindricalSpace ||
         space is LeapSphericalSpace)
     {
         return(SupportInfo.FullSupport());
     }
     else
     {
         return(SupportInfo.Error("Dynamic Renderer does not support " + space.GetType().Name));
     }
 }
        public override SupportInfo GetSupportInfo(LeapGraphicGroup group)
        {
            foreach (var feature in group.features)
            {
                if (feature == this)
                {
                    continue;
                }

                var channelFeature = feature as ICustomChannelFeature;
                if (channelFeature != null && channelFeature.channelName == channelName)
                {
                    return(SupportInfo.Error("Cannot have two custom channels with the same name."));
                }
            }

            return(SupportInfo.FullSupport());
        }
        public void RebuildFeatureSupportInfo()
        {
            using (new ProfilerSample("Rebuild Support Info")) {
                var typeToFeatures = new Dictionary <Type, List <LeapGraphicFeatureBase> >();
                foreach (var feature in _features)
                {
                    Type featureType = feature.GetType();
                    List <LeapGraphicFeatureBase> list;
                    if (!typeToFeatures.TryGetValue(featureType, out list))
                    {
                        list = new List <LeapGraphicFeatureBase>();
                        typeToFeatures[featureType] = list;
                    }

                    list.Add(feature);
                }

                var featureToInfo = new Dictionary <LeapGraphicFeatureBase, SupportInfo>();

                foreach (var pair in typeToFeatures)
                {
                    var featureType = pair.Key;
                    var featureList = pair.Value;
                    var infoList    = new List <SupportInfo>().FillEach(featureList.Count, () => SupportInfo.FullSupport());

                    var castList = Activator.CreateInstance(typeof(List <>).MakeGenericType(featureType)) as IList;
                    foreach (var feature in featureList)
                    {
                        castList.Add(feature);
                    }

                    try {
                        if (_renderingMethod.Value == null)
                        {
                            continue;
                        }

                        var interfaceType = typeof(ISupportsFeature <>).MakeGenericType(featureType);
                        if (!interfaceType.IsAssignableFrom(_renderingMethod.Value.GetType()))
                        {
                            infoList.FillEach(() => SupportInfo.Error("This renderer does not support this feature."));
                            continue;
                        }

                        var supportDelegate = interfaceType.GetMethod("GetSupportInfo");

                        if (supportDelegate == null)
                        {
                            Debug.LogError("Could not find support delegate.");
                            continue;
                        }

                        supportDelegate.Invoke(_renderingMethod.Value, new object[] { castList, infoList });
                    } finally {
                        for (int i = 0; i < featureList.Count; i++)
                        {
                            featureToInfo[featureList[i]] = infoList[i];
                        }
                    }
                }

                _supportInfo = new List <SupportInfo>();
                foreach (var feature in _features)
                {
                    _supportInfo.Add(feature.GetSupportInfo(this).OrWorse(featureToInfo[feature]));
                }
            }
        }
Exemplo n.º 9
0
 public virtual SupportInfo GetSupportInfo(LeapGraphicGroup group)
 {
     return(SupportInfo.FullSupport());
 }
Exemplo n.º 10
0
 public override SupportInfo GetSpaceSupportInfo(LeapSpace space)
 {
     return(SupportInfo.FullSupport());
 }