public static void SetPlatformIcons(BuildTargetGroup platform, PlatformIconKind kind, PlatformIcon[] icons) { string platformName = GetPlatformName(platform); IPlatformIconProvider platformIconProvider = GetPlatformIconProvider(platform); if (platformIconProvider == null) { return; } int requiredIconCount = PlatformIcon.GetRequiredPlatformIconsByType(platformIconProvider, kind).Length; PlatformIconStruct[] iconStructs; if (icons == null) { iconStructs = new PlatformIconStruct[0]; } else if (requiredIconCount != icons.Length) { throw new InvalidOperationException(string.Format("Attempting to set an incorrect number of icons for {0} {1} kind, it requires {2} icons but trying to assign {3}.", platform.ToString(), kind.ToString(), requiredIconCount, icons.Length) ); } else { iconStructs = icons.Select( i => i.GetPlatformIconStruct() ).ToArray <PlatformIconStruct>(); } SetPlatformIconsInternal(platformName, iconStructs, kind.kind); }
internal PlatformIconStruct GetPlatformIconStruct() { PlatformIconStruct platformIconStruct = new PlatformIconStruct(); platformIconStruct.Textures = m_Textures.ToArray(); platformIconStruct.Width = m_Width; platformIconStruct.Height = m_Height; platformIconStruct.Kind = m_Kind.kind; platformIconStruct.SubKind = m_iconSubKind; return platformIconStruct; }
void SetIconsForPlatform(BuildTargetGroup targetGroup, PlatformIcon[] icons, PlatformIconKind kind, ref BuildTargetIcons[] allIcons) { var namedBuildTarget = NamedBuildTarget.FromBuildTargetGroup(targetGroup); var platformIconProvider = PlayerSettings.GetPlatformIconProvider(namedBuildTarget); if (platformIconProvider == null) { return; } if (m_RequiredIcons == null) { m_RequiredIcons = new Dictionary <PlatformIconKind, PlatformIcon[]>(); } if (!m_RequiredIcons.ContainsKey(kind)) { var requiredIcons = platformIconProvider.GetRequiredPlatformIcons(); foreach (var requiredIcon in requiredIcons) { if (!m_RequiredIcons.ContainsKey(requiredIcon.Key)) { m_RequiredIcons.Add(requiredIcon.Key, requiredIcon.Value); } } } var requiredIconCount = PlatformIcon.GetRequiredPlatformIconsByType(platformIconProvider, kind, m_RequiredIcons).Length; PlatformIconStruct[] iconStructs; if (icons == null) { iconStructs = new PlatformIconStruct[0]; } else if (requiredIconCount != icons.Length) { throw new InvalidOperationException($"Attempting to set an incorrect number of icons for {namedBuildTarget} {kind} kind, it requires {requiredIconCount} icons but trying to assign {icons.Length}."); } else { iconStructs = icons.Select( i => i.GetPlatformIconStruct() ).ToArray <PlatformIconStruct>(); } allIcons = PlayerSettings.SetIconsForPlatformForTargetIcons(namedBuildTarget.TargetName, iconStructs, kind.kind, allIcons); }
private void DeserializeIcons() { var allIconsList = new List <BuildTargetIcons>(); for (int i = 0; i < m_PlatformIcons.arraySize; i++) { var platform = m_PlatformIcons.GetArrayElementAtIndex(i); var icons = platform.FindPropertyRelative("m_Icons"); var platformName = platform.FindPropertyRelative("m_BuildTarget").stringValue; if (platformName == null || icons.arraySize <= 0) { continue; } var platformIcons = new BuildTargetIcons { BuildTarget = platformName, Icons = new PlatformIconStruct[icons.arraySize] }; for (int j = 0; j < icons.arraySize; j++) { var platformIconsEntry = icons.GetArrayElementAtIndex(j); var icon = new PlatformIconStruct() { Width = platformIconsEntry.FindPropertyRelative("m_Width").intValue, Height = platformIconsEntry.FindPropertyRelative("m_Height").intValue, Kind = platformIconsEntry.FindPropertyRelative("m_Kind").intValue, SubKind = platformIconsEntry.FindPropertyRelative("m_SubKind").stringValue, }; var texturesEntry = platformIconsEntry.FindPropertyRelative("m_Textures"); icon.Textures = new Texture2D[texturesEntry.arraySize]; for (int k = 0; k < texturesEntry.arraySize; k++) { icon.Textures[k] = (Texture2D)texturesEntry.GetArrayElementAtIndex(k).objectReferenceValue; } platformIcons.Icons[j] = icon; } allIconsList.Add(platformIcons); } m_AllIcons = allIconsList.ToArray(); }