Exemplo n.º 1
0
 static void Initialize()
 {
     foreach (var type in typeof(VCSHelper).Assembly.GetExportedTypes())
     {
         var attrib = type.GetCustomAttributes(typeof(VCSImplementationAttribute), false);
         if (attrib.Length > 0 && typeof(AbstractVCSHelper).IsAssignableFrom(type))
         {
             var metadata = attrib[0] as VCSImplementationAttribute;
             var instance = System.Activator.CreateInstance(type) as AbstractVCSHelper;
             if (instance.IsActive)
             {
                 if (Instance == null)
                 {
                     instance.Initialize();
                     Instance = instance;
                     AbstractVCSHelper.SetMetadata(Instance, metadata);
                 }
                 else
                 {
                     Debug.LogError("[VCS] Found multiple valid VCS types: " + metadata.DisplayName + " and " + Instance.Metadata.DisplayName);
                     return;
                 }
             }
         }
     }
     EditorApplication.update += () =>
     {
         if (Instance != null)
         {
             Instance.Update();
         }
     };
 }
Exemplo n.º 2
0
 public static void SetMetadata(AbstractVCSHelper helper, VCSImplementationAttribute metadata)
 {
     helper.Metadata = metadata;
 }