Example #1
0
        private static Sprite LoadSpriteFromResources(string path, float pixelsPerUnit = 100F)
        {
            path = "CrewOfSalem.Resources." + path;
            try
            {
                Texture2D texture2D   = GUIExtensions.CreateEmptyTexture();
                var       assembly    = Assembly.GetExecutingAssembly();
                Stream    stream      = assembly.GetManifestResourceStream(path);
                byte[]    byteTexture = stream.ReadFully();
                ImageConversion.LoadImage(texture2D, byteTexture, false);
                return(Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height),
                                     new Vector2(0.5F, 0.5F), pixelsPerUnit).DontDestroy());
            }
            catch
            {
                ConsoleTools.Error("Failed loading sprites from path: " + path);
            }

            return(null);
        }
Example #2
0
        public void End()
        {
            float time = (DateTime.UtcNow - startTime).Milliseconds;

            ConsoleTools.Info("Benchmark " + name + " took " + time + " milliseconds");
        }