예제 #1
0
        private void GenerateFromTypes(Type baseType)
        {
            bufferData.Clear();
            Type        scriptBaseType = _dataAttribute.ScriptBaseType;
            List <Type> filteredTypes  = LSEditorUtility.GetFilteredTypes(scriptBaseType);

            DataItem[]     data         = Data as DataItem[];
            HashSet <Type> lackingTypes = new HashSet <Type> (filteredTypes);

            for (int i = 0; i < data.Length; i++)
            {
                DataItem       item       = data[i];
                ScriptDataItem scriptItem = item as ScriptDataItem;
                if (lackingTypes.Remove(scriptItem.Script))
                {
                    bufferData.Add(item);
                }
            }
            foreach (Type type in lackingTypes)
            {
                DataItem item = (DataItem)Activator.CreateInstance((TargetType));
                item.Inject(type);
                item.Name = (type.Name);
                bufferData.Add(item);
            }
            DataItem[] tempData = (DataItem[])Array.CreateInstance(TargetType, bufferData.Count);
            bufferData.CopyTo(tempData);
            Data = tempData;
        }
예제 #2
0
        private void GenerateFromTypes(Type baseType)
        {
            bufferData.Clear();
            Type        scriptBaseType = _dataAttribute.ScriptBaseType;
            List <Type> filteredTypes  = LSEditorUtility.GetFilteredTypes(scriptBaseType);

            DataItem[]     data              = Data as DataItem[];
            HashSet <Type> lackingTypes      = new HashSet <Type> ();
            Type           abilityType       = typeof(Ability);
            Type           activeAbilityType = typeof(ActiveAbility);

            for (int i = 0; i < filteredTypes.Count; i++)
            {
                if (filteredTypes[i].BaseType != abilityType && filteredTypes[i].BaseType != activeAbilityType)
                {
                    if (filteredTypes[i].GetCustomAttributes(typeof(CustomActiveAbilityAttribute), false).Length == 0)
                    {
                        continue;
                    }
                }
                lackingTypes.Add(filteredTypes[i]);
            }
            for (int i = 0; i < data.Length; i++)
            {
                DataItem       item       = data[i];
                ScriptDataItem scriptItem = item as ScriptDataItem;
                if (lackingTypes.Remove(scriptItem.Script))
                {
                    bufferData.Add(item);
                }
            }
            foreach (Type type in lackingTypes)
            {
                DataItem item = (DataItem)Activator.CreateInstance((TargetType));
                item.Inject(type);
                bufferData.Add(item);
            }
            DataItem[] tempData = (DataItem[])Array.CreateInstance(TargetType, bufferData.Count);
            bufferData.CopyTo(tempData);
            Data = tempData;
        }