コード例 #1
0
        void OnGUI()
        {
            GUILayout.Label("SerializationUtil");
            if (GUILayout.Button("Serialize Object to Desktop"))
            {
                var obj = new ThingToSerialize();
                Debug.Log(obj);
                SerializationUtil.serializeObjectToFile(obj, "Thingy.bin", Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
            }

            if (GUILayout.Button("Deserialize Object from Desktop"))
            {
                var obj = SerializationUtil.deserializeObjectFromFile <ThingToSerialize>("Thingy.bin", Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                Debug.Log(obj);
            }


            GUILayout.Label("Utils");
            if (GUILayout.Button("map01 Example"))
            {
                // maps a number (75 in this case) from a range of 5 - 250 to a range of 0 - 1
                Debug.Log("mapped: " + MathHelpers.map01(75f, 5f, 250f));
            }


            GUILayout.Label("SpriteAnimator");
            if (GUILayout.Button("Sprite: Play walk-left Animation"))
            {
                var animationIndex = _spriteAnimator.animationIndexForAnimationName("walk-left");
                _spriteAnimator.play(animationIndex);
            }

            if (GUILayout.Button("Sprite: Play blue-dude-walk-right Animation"))
            {
                //blue-dude-walk-right
                var animationIndex = _spriteAnimator.animationIndexForAnimationName("blue-dude-walk-right");
                _spriteAnimator.play(animationIndex);
            }

            if (GUILayout.Button("Sprite: Play blood-splatter Animation"))
            {
                //blood-splatter
                var animationIndex = _spriteAnimator.animationIndexForAnimationName("blood-splatter");
                _spriteAnimator.play(animationIndex);
            }
        }
コード例 #2
0
        void OnGUI()
        {
            GUILayout.Label("SerializationUtil");
            if (GUILayout.Button("Serialize Object to Desktop"))
            {
                var obj = new ThingToSerialize();
                Debug.Log(obj);
                SerializationUtil.serializeObjectToFile(obj, "Thingy.bin", Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
            }

            if (GUILayout.Button("Deserialize Object from Desktop"))
            {
                var obj = SerializationUtil.deserializeObjectFromFile<ThingToSerialize>("Thingy.bin", Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                Debug.Log(obj);
            }

            GUILayout.Label("Utils");
            if (GUILayout.Button("map01 Example"))
            {
                // maps a number (75 in this case) from a range of 5 - 250 to a range of 0 - 1
                Debug.Log("mapped: " + MathHelpers.map01(75f, 5f, 250f));
            }

            GUILayout.Label("SpriteAnimator");
            if (GUILayout.Button("Sprite: Play walk-left Animation"))
            {
                var animationIndex = _spriteAnimator.animationIndexForAnimationName("walk-left");
                _spriteAnimator.play(animationIndex);
            }

            if (GUILayout.Button("Sprite: Play blue-dude-walk-right Animation"))
            {
                //blue-dude-walk-right
                var animationIndex = _spriteAnimator.animationIndexForAnimationName("blue-dude-walk-right");
                _spriteAnimator.play(animationIndex);
            }

            if (GUILayout.Button("Sprite: Play blood-splatter Animation"))
            {
                //blood-splatter
                var animationIndex = _spriteAnimator.animationIndexForAnimationName("blood-splatter");
                _spriteAnimator.play(animationIndex);
            }
        }