Esempio 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."));
                }
            }
        }
Esempio 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.");
     }
 }
Esempio 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());
     }
 }
Esempio 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."));
         }
     }
 }
Esempio n. 5
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]));
                }
            }
        }