示例#1
0
 public MemberOptionTree(IEnumerable <Type> types, MemberFilter memberFilter, TypeFilter memberTypeFilter, ActionDirection direction) : base(new GUIContent("Member"))
 {
     favorites        = new Favorites(this);
     codebase         = Codebase.Subset(types, memberFilter.Configured(), memberTypeFilter?.Configured(false));
     this.direction   = direction;
     expectingBoolean = memberTypeFilter?.ExpectsBoolean ?? false;
 }
        public override void LateInitialize()
        {
            base.LateInitialize();

            // Add all plugin runtime assemblies to the option list

            var missingPluginAssemblies = new List <LooseAssemblyName>();

            foreach (var pluginAssembly in PluginContainer.plugins.SelectMany(plugin => plugin.GetType().GetAttributes <PluginRuntimeAssemblyAttribute>().Select(a => a.assemblyName)).Distinct())
            {
                if (!assemblyOptions.Contains(pluginAssembly))
                {
                    missingPluginAssemblies.Add(pluginAssembly);
                }
            }

            if (missingPluginAssemblies.Any())
            {
                var assemblyOptionsMetadata = projectSettings.Single(metadata => metadata.key == nameof(assemblyOptions));

                assemblyOptions.AddRange(missingPluginAssemblies);
                assemblyOptionsMetadata.defaultValue = ((List <LooseAssemblyName>)assemblyOptionsMetadata.defaultValue).Concat(missingPluginAssemblies).ToList();

                Save();
            }

            Codebase.UpdateSettings();
        }
        public void GenerateProviderScripts()
        {
            if (Directory.Exists(LudiqCore.Paths.propertyProviders))
            {
                foreach (var file in Directory.GetFiles(LudiqCore.Paths.propertyProviders))
                {
                    File.Delete(file);
                }
            }

            if (Directory.Exists(LudiqCore.Paths.propertyProvidersEditor))
            {
                foreach (var file in Directory.GetFiles(LudiqCore.Paths.propertyProvidersEditor))
                {
                    File.Delete(file);
                }
            }

            PathUtility.CreateDirectoryIfNeeded(LudiqCore.Paths.propertyProviders);
            PathUtility.CreateDirectoryIfNeeded(LudiqCore.Paths.propertyProvidersEditor);

            foreach (var type in typeset.Where(SerializedPropertyUtility.HasCustomDrawer))
            {
                var directory = Codebase.IsEditorType(type) ? LudiqCore.Paths.propertyProvidersEditor : LudiqCore.Paths.propertyProviders;
                var path      = Path.Combine(directory, GetProviderScriptName(type) + ".cs");

                VersionControlUtility.Unlock(path);
                File.WriteAllText(path, GenerateProviderSource(type));
            }

            AssetDatabase.Refresh();
        }
        private static IEnumerable <object> FindAllSettingsStubs()
        {
            // Include all custom operators for the formula unit and generic math units
            // Also include all user defined conversion operators for the conversion utility
            var codebaseSubset = Codebase.Subset(Codebase.settingsTypes, TypeFilter.Any.Configured(), MemberFilter.Any.Configured());

            codebaseSubset.Cache();

            return(codebaseSubset.members
                   .Select(m => m.info)
                   .OfType <MethodInfo>()
                   .Where(m => m.IsOperator() || m.IsUserDefinedConversion())
                   .Cast <object>());
        }
 private IFuzzyOptionTree GetOptions()
 {
     return(new TypeOptionTree(Codebase.GetTypeSetFromAttribute(metadata), typeFilter));
 }
 private IFuzzyOptionTree GetOptions()
 {
     return(new MemberOptionTree(Codebase.GetTypeSetFromAttribute(metadata), memberFilter, memberTypeFilter, direction));
 }