public static System.Type GetWrapperType(System.Type type)
 {
     try
     {
         if (string.Equals(type.Namespace, "PixelCrushers.QuestMachine"))
         {
             var wrapperName = "PixelCrushers.QuestMachine.Wrappers." + type.Name;
             var assemblies  = RuntimeTypeUtility.GetAssemblies();
             foreach (var assembly in assemblies)
             {
                 try
                 {
                     var wrapperList = (from assemblyType in assembly.GetExportedTypes()
                                        where string.Equals(assemblyType.FullName, wrapperName)
                                        select assemblyType).ToArray();
                     if (wrapperList.Length > 0)
                     {
                         return(wrapperList[0]);
                     }
                 }
                 catch (System.Exception)
                 {
                     // Ignore exceptions and try next assembly.
                 }
             }
         }
     }
     catch (System.Exception)
     {
         // Ignore exceptions.
     }
     return(null);
 }
Пример #2
0
        private static List <Type> FindAllDerivedTypes <T>()
        {
            var list = new List <Type>();

            try
            {
                var derivedType = typeof(T);
                var assemblies  = RuntimeTypeUtility.GetAssemblies();
                foreach (var assembly in assemblies)
                {
                    try
                    {
                        var wrapperList = (from assemblyType in assembly.GetExportedTypes()
                                           where derivedType.IsAssignableFrom(assemblyType) && assemblyType != derivedType
                                           select assemblyType).ToArray();
                        list.AddRange(wrapperList);
                    }
                    catch (System.Exception)
                    {
                        // If error, ignore assembly and move on.
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogWarning("Dialogue Editor: FindAllDerivedTypes error: " + e.Message + ". Please contact [email protected].");
            }
            return(list);
        }
        protected override void CreateNewAsset(List <AssetInfo> assetInfoList)
        {
            // Create a list of all urgency function types, excluding abstract types and
            // types that have wrappers:
            var list       = new List <System.Type>();
            var assemblies = RuntimeTypeUtility.GetAssemblies();

            foreach (var assembly in assemblies)
            {
                try
                {
                    var assemblyList = (from assemblyType in assembly.GetExportedTypes()
                                        where typeof(UrgencyFunction).IsAssignableFrom(assemblyType)
                                        select assemblyType).ToArray();
                    list.AddRange(assemblyList);
                }
                catch (System.Exception)
                {
                    // Ignore exceptions and move on to next assembly.
                }
            }
            var menu = new GenericMenu();

            for (int i = 0; i < list.Count; i++)
            {
                var type = list[i];
                if (type == null)
                {
                    continue;
                }
                if (type.IsAbstract)
                {
                    continue;
                }
                if (QuestEditorUtility.HasWrapperType(type))
                {
                    continue;
                }
                menu.AddItem(new GUIContent(type.Name), false, OnClickNewUrgencyFunction, type);
            }
            menu.ShowAsContext();
        }
Пример #4
0
        private static void AddAllSequencerCommands(GenericMenu menu)
        {
            var list       = new List <string>(InternalSequencerCommands);
            var assemblies = RuntimeTypeUtility.GetAssemblies();

            for (int i = 0; i < assemblies.Length; i++)
            {
                var assembly = assemblies[i];
                try
                {
                    foreach (var type in assembly.GetTypes().Where(t => typeof(PixelCrushers.DialogueSystem.SequencerCommands.SequencerCommand).IsAssignableFrom(t)))
                    {
                        var commandName = type.Name.Substring("SequencerCommand".Length);
                        list.Add(commandName);
                    }
                }
                catch (System.Exception) { }
            }
            list.Sort();
            for (int i = 0; i < list.Count; i++)
            {
                menu.AddItem(new GUIContent("All Sequencer Commands/" + list[i]), false, StartSequencerCommand, list[i]);
            }
        }