Пример #1
0
        public static IEnumerable <Warning> Warnings(FlowGraph graph, IEnumerable <IUnitPortDefinition> definitions = null)
        {
            if (definitions == null)
            {
                definitions = LinqUtility.Concat <IUnitPortDefinition>(graph.controlInputDefinitions,
                                                                       graph.controlOutputDefinitions,
                                                                       graph.valueInputDefinitions,
                                                                       graph.valueOutputDefinitions);
            }

            var hasDuplicate = definitions.DistinctBy(d => d.key).Count() != definitions.Count();

            if (hasDuplicate)
            {
                yield return(Warning.Caution("Some port definitions with non-unique keys are currently ignored."));
            }

            foreach (var definition in definitions)
            {
                if (!definition.isValid)
                {
                    yield return(InvalidWarning(definition));
                }
            }
        }
Пример #2
0
        protected virtual IEnumerable <MemberInfo> GetMembers(Type type)
        {
            var bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

            return(LinqUtility.Concat <MemberInfo>
                   (
                       type.GetFields(bindingFlags).Where(IncludeField),
                       type.GetProperties(bindingFlags).Where(IncludeProperty)
                   ));
        }
Пример #3
0
        private IEnumerable <object> FindAllAssetStubs()
        {
            return(LinqUtility.Concat <object>
                   (
                       AssetUtility.GetAllAssetsOfType <IAotStubbable>()
                       .SelectMany(aot => aot.aotStubs),

                       AssetUtility.GetAllAssetsOfType <GameObject>()
                       .SelectMany(go => go.GetComponents <IAotStubbable>()
                                   .SelectMany(component => component.aotStubs))
                   ));
        }
Пример #4
0
        public static IEnumerable <IUnitOption> Subset(UnitOptionFilter filter, GraphReference reference)
        {
            lock (@lock)
            {
                if (options == null)
                {
                    Load();
                }

                var dynamicOptions    = UnityAPI.Await(() => GetDynamicOptions().ToHashSet());
                var contextualOptions = UnityAPI.Await(() => GetContextualOptions(reference).ToHashSet());

                return(LinqUtility.Concat <IUnitOption>(options, dynamicOptions, contextualOptions)
                       .Where((filter ?? UnitOptionFilter.Any).ValidateOption)
                       .ToArray());
            }
        }
Пример #5
0
 public override IEnumerable <object> GetAotStubs(HashSet <object> visited)
 {
     return(LinqUtility.Concat <object>(base.GetAotStubs(visited), nest.GetAotStubs(visited)));
 }
        protected override IEnumerable <Warning> Warnings()
        {
            foreach (var baseWarning in base.Warnings())
            {
                yield return(baseWarning);
            }

            if (unit.graph != null)
            {
                foreach (var definitionWarning in UnitPortDefinitionUtility.Warnings(unit.graph, LinqUtility.Concat <IUnitPortDefinition>(unit.graph.controlInputDefinitions, unit.graph.valueInputDefinitions)))
                {
                    yield return(definitionWarning);
                }
            }
        }
Пример #7
0
 public static IEnumerable <string> GetVariableNameSuggestions(VariableKind kind, GraphReference reference)
 {
     return(LinqUtility.Concat <string>(GetPredefinedVariableNames(kind, reference), GetDynamicVariableNames(kind, reference)).Distinct().OrderBy(name => name));
 }
        protected override IEnumerable <Warning> Warnings()
        {
            foreach (var baseWarning in base.Warnings())
            {
                yield return(baseWarning);
            }

            if (unit.graph != null)
            {
                foreach (var definitionWarning in UnitPortDefinitionUtility.Warnings(unit.graph, LinqUtility.Concat <IUnitPortDefinition>(unit.graph.controlOutputDefinitions, unit.graph.valueOutputDefinitions)))
                {
                    yield return(definitionWarning);
                }

                if (unit.graph.units.Count(unit => unit is GraphOutput) > 1)
                {
                    yield return(Warning.Caution("Multiple output nodes in the same graph. Only one of them will be used."));
                }
            }
        }
        protected override IEnumerable <Warning> Warnings()
        {
            foreach (var baseWarning in base.Warnings())
            {
                yield return(baseWarning);
            }

            if (unit.graph != null)
            {
                foreach (var definitionWarning in UnitPortDefinitionUtility.Warnings(unit.graph, LinqUtility.Concat <IUnitPortDefinition>(unit.graph.controlInputDefinitions, unit.graph.valueInputDefinitions)))
                {
                    yield return(definitionWarning);
                }

                var inputs = unit.graph.units.Where(u => u is GraphInput).ToList();
                if (inputs.Count > 1)
                {
                    var firstInput = inputs[0];
                    if (unit != firstInput)
                    {
                        var graphName = string.IsNullOrEmpty(unit.graph.title) ? nameof(SubgraphUnit) : unit.graph.title;
                        Debug.LogWarning($"Only one Input node can be used and will execute in {graphName}.");
                        yield return(Warning.Caution("Only one Input node can be used and will execute."));
                    }
                }
            }
        }