UnrealBuildTool的UnrealPlatformGroupUnreal4-源码拆解-UnrealBuildTool功能流程解析

Unreal4源码拆解-UnrealBuildTool功能流程解析-UnrealBuildTool的UnrealPlatformGroup

知乎专栏:UBT源码解析

前言

  • 我们构建的目标组织类,其实就是由一个名称和一个ID组成
  • 在UEBuildPlatform类中保存了
    Dictionary<UnrealPlatformGroup, List<UnrealTargetPlatform>> PlatformGroupDictionary
  • 也是意味着一个组织UnrealPlatformGroup可以对应多个平台UnrealTargetPlatform
  • 比如apple对应iosmac等等
  • UniqueStringRegistry强耦合,UniqueStringRegistry可以看:

类 public partial struct UnrealPlatformGroup

成员变量

private int Id;

private static UniqueStringRegistry StringRegistry;

  • 主要功能:利用UniqueStringRegistry存了一个ID和一个独特字符串

public static UnrealPlatformGroup Windows = FindOrAddByName(“Windows”);

public static UnrealPlatformGroup HoloLens = FindOrAddByName(“HoloLens”);

public static UnrealPlatformGroup Microsoft = FindOrAddByName(“Microsoft”);

public static UnrealPlatformGroup Apple = FindOrAddByName(“Apple”);

public static UnrealPlatformGroup IOS = FindOrAddByName(“IOS”);

public static UnrealPlatformGroup Unix = FindOrAddByName(“Unix”);

public static UnrealPlatformGroup Linux = FindOrAddByName(“Linux”);

public static UnrealPlatformGroup Android = FindOrAddByName(“Android”);

public static UnrealPlatformGroup Sony = FindOrAddByName(“Sony”);

public static UnrealPlatformGroup XboxCommon = FindOrAddByName(“XboxCommon”);

public static UnrealPlatformGroup AllDesktop = FindOrAddByName(“AllDesktop”);

public static UnrealPlatformGroup Desktop = FindOrAddByName(“Desktop”);

  • 主要功能:在main函数执行之前注册字符串和ID
  • 我们可以看到具体内容
    • UnrealPlatformGroup Name is Windows ID is 0
    • UnrealPlatformGroup Name is HoloLens ID is 1
    • UnrealPlatformGroup Name is Microsoft ID is 2
    • UnrealPlatformGroup Name is Apple ID is 3
    • UnrealPlatformGroup Name is IOS ID is 4
    • UnrealPlatformGroup Name is Unix ID is 5
    • UnrealPlatformGroup Name is Linux ID is 6
    • UnrealPlatformGroup Name is Android ID is 7
    • UnrealPlatformGroup Name is Sony ID is 8
    • UnrealPlatformGroup Name is XboxCommon ID is 9
    • UnrealPlatformGroup Name is AllDesktop ID is 10
    • UnrealPlatformGroup Name is Desktop ID is 11
  • 所以我们可以看到其实UnrealPlatformGroup就是由一个ID和一个平台名称组成的。

成员函数

private static UniqueStringRegistry GetUniqueStringRegistry()

  • 创建UniqueStringRegistry实例,所有UnrealPlatformGroup类实例共用一个。

static private UnrealPlatformGroup FindOrAddByName(string Name)

  • 新建一个UnrealPlatformGroup实例,注册独特字符串,获取ID存到UnrealPlatformGroup实例中。

public static bool operator ==(UnrealPlatformGroup A, UnrealPlatformGroup B)

public static bool operator !=(UnrealPlatformGroup A, UnrealPlatformGroup B)

public override bool Equals(object B)

  • 判断两个UnrealPlatformGroup的ID是否相同

public override int GetHashCode()

  • 直接用ID当作哈希值

public override string ToString()

  • 返回独特字符串

public static UnrealPlatformGroup[] GetValidGroups()

  • 根据类内的UniqueStringRegistry的所有字符串和ID,创建一大串新的UnrealPlatformGroup,返回。

public static string[] GetValidGroupNames()

  • 返回类内的UniqueStringRegistry的所有字符串

public static bool IsValidName(string Name)

  • 返回类内的UniqueStringRegistry中是否有输入参数的独特字符串
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值