-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/add-entity-id-to-remote-folder-path
- Loading branch information
Showing
5 changed files
with
146 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
asset-bundle-converter/Assets/AssetBundleConverter/TextureTypeManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using UnityEngine; | ||
using System.Collections.Generic; | ||
|
||
[System.Flags] | ||
public enum TextureType | ||
{ | ||
None = 0, | ||
MainTex = 1 << 0, | ||
BaseMap = 1 << 1, | ||
BumpMap = 1 << 2, | ||
MetallicGlossMap = 1 << 3, | ||
ParallaxMap = 1 << 4, | ||
OcclusionMap = 1 << 5, | ||
EmissionMap = 1 << 6, | ||
SpecGlossMap = 1 << 7 | ||
} | ||
|
||
public struct TextureInfo | ||
{ | ||
public string Name; | ||
public TextureType Types; | ||
|
||
public TextureInfo(string name) | ||
{ | ||
Name = name; | ||
Types = TextureType.None; | ||
} | ||
} | ||
|
||
public static class TextureInfoExtensions | ||
{ | ||
public static TextureType GetTextureTypeFromString(string input) | ||
{ | ||
switch (input) | ||
{ | ||
case "_MainTex" : | ||
return TextureType.MainTex; | ||
case "_BaseMap" : | ||
return TextureType.BaseMap; | ||
case "_BumpMap" : | ||
return TextureType.BumpMap; | ||
case "_MetallicGlossMap" : | ||
return TextureType.MetallicGlossMap; | ||
case "_ParallaxMap" : | ||
return TextureType.ParallaxMap; | ||
case "_OcclusionMap" : | ||
return TextureType.OcclusionMap; | ||
case "_EmissionMap" : | ||
return TextureType.EmissionMap; | ||
case "_SpecGlossMap" : | ||
return TextureType.SpecGlossMap; | ||
default : | ||
return TextureType.None; | ||
} | ||
} | ||
|
||
|
||
|
||
public static TextureInfo AddType(this TextureInfo info, TextureType type) | ||
{ | ||
info.Types |= type; | ||
return info; | ||
} | ||
|
||
public static TextureInfo RemoveType(this TextureInfo info, TextureType type) | ||
{ | ||
info.Types &= ~type; | ||
return info; | ||
} | ||
|
||
public static bool HasType(this TextureInfo info, TextureType type) | ||
{ | ||
return (info.Types & type) != 0; | ||
} | ||
|
||
public static bool HasAnyType(this TextureInfo info, TextureType types) | ||
{ | ||
return (info.Types & types) != 0; | ||
} | ||
|
||
public static bool HasAllTypes(this TextureInfo info, TextureType types) | ||
{ | ||
return (info.Types & types) == types; | ||
} | ||
|
||
public static string GetTypesString(this TextureInfo info) | ||
{ | ||
return $"{info.Name}: {info.Types}"; | ||
} | ||
} | ||
|
||
public class TextureTypeManager : MonoBehaviour | ||
{ | ||
private Dictionary<string, TextureInfo> textureInfos = new Dictionary<string, TextureInfo>(); | ||
|
||
public void AddTextureType(string textureName, TextureType type) | ||
{ | ||
if (!textureInfos.TryGetValue(textureName, out TextureInfo info)) | ||
{ | ||
info = new TextureInfo(textureName); | ||
} | ||
textureInfos[textureName] = info.AddType(type); | ||
} | ||
|
||
public TextureInfo GetTextureInfo(string textureName) | ||
{ | ||
return textureInfos.TryGetValue(textureName, out TextureInfo info) ? info : new TextureInfo(textureName); | ||
} | ||
|
||
public bool HasTextureType(string textureName, TextureType type) | ||
{ | ||
return textureInfos.TryGetValue(textureName, out TextureInfo info) && info.HasType(type); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
asset-bundle-converter/Assets/AssetBundleConverter/TextureTypeManager.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
asset-bundle-converter/Assets/git-submodules/unity-shared-dependencies
Submodule unity-shared-dependencies
updated
30 files