public Sprite getSprite(string spriteSheet, string unityName) { //if it's a proper unityName with offset int uOffset = DmiIcon.getOffsetFromUnityName(unityName); if (!uOffset.Equals(-1)) { return(getSprite(spriteSheet, uOffset)); } //if it's something custom ,like tileconnect handwritten stuff DmiIcon icon = getIconBySheet(spriteSheet); if (!icon.getName().Equals("")) { DmiState dmiState = icon.states.Find(state => state.unityName.Equals(unityName)); if (dmiState != null) { int offset = dmiState.offset; if (icon.spriteSheet.Length > offset && !offset.Equals(-1)) { return(icon.spriteSheet[offset]); } } Logger.LogErrorFormat("Couldn't find sprite by UN: {0}({1}) in {2}", Category.DmMetadata, spriteSheet, unityName, icon.icon); } return(new Sprite()); }
public Sprite getSpriteFromLegacyName(string spriteSheet, string legacyUnityName) { string iPath = getIconPath(spriteSheet); if (legacyData.ContainsKey(iPath)) { DmiIcon icon = legacyData[iPath]; int legacyOffset = DmiIcon.getOffsetFromUnityName(legacyUnityName); int relativeOffset; DmiState legacyDmiState = icon.getStateAtOffset(legacyOffset, out relativeOffset); if (legacyDmiState != null && Data.ContainsKey(iPath)) { string legacyState = legacyDmiState.state; DmiState newState = Data[iPath].getState(legacyState); //searchStateInIcon(legacyState, spriteSheet, false); if (newState != null) { // if (legacyUnityName.Contains("shuttle_wall")) // { // Logger.Log("found ya!"); // } return(getSprite(spriteSheet, newState.offset + relativeOffset)); } } } Logger.LogErrorFormat("failed to getSpriteFromLegacyName: {0} {1}", Category.DmMetadata, spriteSheet, legacyUnityName); return(new Sprite()); }