Пример #1
0
        public static int AddSpriteToCollection(string resourcePath, tk2dSpriteCollectionData collection)
        {
            string str = (!resourcePath.EndsWith(".png")) ? ".png" : "";

            resourcePath += str;
            Texture2D            textureFromResource  = ResourceExtractor.GetTextureFromResource(resourcePath);
            tk2dSpriteDefinition tk2dSpriteDefinition = ConstructDefinition(textureFromResource);

            tk2dSpriteDefinition.name = textureFromResource.name;
            return(AddSpriteToCollection(tk2dSpriteDefinition, collection));
        }
Пример #2
0
 public static void AddSpritesToCollection(List <string> ResourceNames, tk2dSpriteCollectionData collection)
 {
     foreach (string ResourceName in ResourceNames)
     {
         string resourcePath = ResourceName;
         string str          = (!resourcePath.EndsWith(".png")) ? ".png" : "";
         resourcePath += str;
         Texture2D            textureFromResource  = ResourceExtractor.GetTextureFromResource(resourcePath);
         tk2dSpriteDefinition tk2dSpriteDefinition = ConstructDefinition(textureFromResource);
         tk2dSpriteDefinition.name = textureFromResource.name;
         AddSpriteToCollection(tk2dSpriteDefinition, collection);
     }
 }
Пример #3
0
 public static void Init()
 {
     FakePrefabHooks.Init();
     // CompanionBuilder.Init();
     try {
         MethodBase method        = new StackFrame(1, false).GetMethod();
         Type       declaringType = method.DeclaringType;
         ResourceExtractor.SetAssembly(declaringType);
     } catch (Exception ex) {
         ETGModConsole.Log(ex.Message, false);
         ETGModConsole.Log(ex.StackTrace, false);
     }
 }
Пример #4
0
        public static GameObject SpriteFromFile(string spriteName, GameObject obj = null, bool copyFromExisting = true)
        {
            string     fileName        = spriteName.Replace(".png", "");
            Texture2D  textureFromFile = ResourceExtractor.GetTextureFromFile(fileName);
            bool       flag            = textureFromFile == null;
            GameObject result;

            if (flag)
            {
                result = null;
            }
            else
            {
                result = SpriteFromTexture(textureFromFile, spriteName, obj, copyFromExisting);
            }
            return(result);
        }
Пример #5
0
        public static GameObject SpriteFromResource(string spriteName, GameObject obj = null, bool copyFromExisting = true)
        {
            string     str  = (!spriteName.EndsWith(".png")) ? ".png" : "";
            string     text = spriteName + str;
            Texture2D  textureFromResource = ResourceExtractor.GetTextureFromResource(text);
            bool       flag = textureFromResource == null;
            GameObject result;

            if (flag)
            {
                result = null;
            }
            else
            {
                result = SpriteFromTexture(textureFromResource, text, obj, copyFromExisting);
            }
            return(result);
        }