Esempio n. 1
0
        /// <summary>
        /// Saves a preset as a new file. Note: Check if the file exists before calling this method.
        /// </summary>
        /// <param name="preset"></param>
        /// <param name="category"></param>
        /// <param name="presetName"></param>
        public static void SavePreset(AnimatorPreset preset, string category, string presetName)
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Create(GetPresetsPath + "/" + category + "/" + presetName + "." + PresetHelper.PRESET_EXTENSION);

            bf.Serialize(file, preset);
            file.Close();
        }
Esempio n. 2
0
        /// <summary>
        /// Loads a preset from a file. Note: Check that the file exists before calling this method.
        /// </summary>
        /// <param name="category"></param>
        /// <param name="presetName"></param>
        /// <returns></returns>
        public static AnimatorPreset LoadPreset(string category, string presetName)
        {
            if (!File.Exists(GetPresetsPath + "/" + category + "/" + presetName + "." + PresetHelper.PRESET_EXTENSION))
            {
                return(null);
            }

            BinaryFormatter bf = new BinaryFormatter();

#if UNITY_EDITOR
            FileStream file = File.Open(GetPresetsPath + "/" + category + "/" + presetName + "." + PresetHelper.PRESET_EXTENSION, FileMode.Open);
#else
            FileStream file = File.Open(Application.persistentDataPath + "/Plugins/DoozyUI/UIButton/Resources/" + category + "/" + presetName + "." + PresetHelper.PRESET_EXTENSION, FileMode.Open);
#endif
            AnimatorPreset preset = (AnimatorPreset)bf.Deserialize(file);
            file.Close();
            return(preset);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns an AnimatorPreset with all the values of the animator module.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        public AnimatorPreset GetPresetValues()
        {
            AnimatorPreset preset = new AnimatorPreset();

            //PunchMove
            preset.pm_enabled    = punchMove.enabled;
            preset.pm_punch_x    = punchMove.punch.x;
            preset.pm_punch_y    = punchMove.punch.y;
            preset.pm_punch_z    = punchMove.punch.z;
            preset.pm_snapping   = punchMove.snapping;
            preset.pm_duration   = punchMove.duration;
            preset.pm_delay      = punchMove.delay;
            preset.pm_vibrato    = punchMove.vibrato;
            preset.pm_elasticity = punchMove.elasticity;

            //PunchRotate
            preset.pr_enabled    = punchRotate.enabled;
            preset.pr_punch_x    = punchRotate.punch.x;
            preset.pr_punch_y    = punchRotate.punch.y;
            preset.pr_punch_z    = punchRotate.punch.z;
            preset.pr_duration   = punchRotate.duration;
            preset.pr_delay      = punchRotate.delay;
            preset.pr_vibrato    = punchRotate.vibrato;
            preset.pr_elasticity = punchRotate.elasticity;

            //PunchScale
            preset.ps_enabled    = punchScale.enabled;
            preset.ps_punch_x    = punchScale.punch.x;
            preset.ps_punch_y    = punchScale.punch.y;
            preset.ps_punch_z    = punchScale.punch.z;
            preset.ps_duration   = punchScale.duration;
            preset.ps_delay      = punchScale.delay;
            preset.ps_vibrato    = punchScale.vibrato;
            preset.ps_elasticity = punchScale.elasticity;

            //Move
            preset.m_enabled          = move.enabled;
            preset.m_to_x             = move.to.x;
            preset.m_to_y             = move.to.y;
            preset.m_to_z             = move.to.z;
            preset.m_relative         = move.relative;
            preset.m_snapping         = move.snapping;
            preset.m_duration         = move.duration;
            preset.m_delay            = move.delay;
            preset.m_ease             = move.ease;
            preset.m_reverseAfterTime = move.reverseAfterTime;
            preset.m_reverseDuration  = move.reverseDuration;
            preset.m_reverseDelay     = move.reverseDelay;
            preset.m_reverseEase      = move.reverseEase;

            //Rotate
            preset.r_enabled          = rotate.enabled;
            preset.r_to_x             = rotate.to.x;
            preset.r_to_y             = rotate.to.y;
            preset.r_to_z             = rotate.to.z;
            preset.r_relative         = rotate.relative;
            preset.r_duration         = rotate.duration;
            preset.r_delay            = rotate.delay;
            preset.r_ease             = rotate.ease;
            preset.r_reverseAfterTime = rotate.reverseAfterTime;
            preset.r_reverseDuration  = rotate.reverseDuration;
            preset.r_reverseDelay     = rotate.reverseDelay;
            preset.r_reverseEase      = rotate.reverseEase;

            //Scale
            preset.s_enabled          = scale.enabled;
            preset.s_to_x             = scale.to.x;
            preset.s_to_y             = scale.to.y;
            preset.s_to_z             = scale.to.z;
            preset.s_relative         = scale.relative;
            preset.s_duration         = scale.duration;
            preset.s_delay            = scale.delay;
            preset.s_ease             = scale.ease;
            preset.s_reverseAfterTime = scale.reverseAfterTime;
            preset.s_reverseDuration  = scale.reverseDuration;
            preset.s_reverseDelay     = scale.reverseDelay;
            preset.s_reverseEase      = scale.reverseEase;

            //Fade
            preset.f_enabled          = fade.enabled;
            preset.f_to               = fade.to;
            preset.f_relative         = fade.relative;
            preset.f_duration         = fade.duration;
            preset.f_delay            = fade.delay;
            preset.f_ease             = fade.ease;
            preset.f_reverseAfterTime = fade.reverseAfterTime;
            preset.f_reverseDuration  = fade.reverseDuration;
            preset.f_reverseDelay     = fade.reverseDelay;
            preset.f_reverseEase      = fade.reverseEase;

            return(preset);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the values from the source AnimatorPreset and overrides the animator module's values.
        /// </summary>
        /// <param name="source"></param>
        public void SetPresetValues(AnimatorPreset source)
        {
            if (source == null)
            {
                return;
            }

            punchMove.enabled    = source.pm_enabled;
            punchMove.punch      = new Vector3(source.pm_punch_x, source.pm_punch_y, source.pm_punch_z);
            punchMove.snapping   = source.pm_snapping;
            punchMove.duration   = source.pm_duration;
            punchMove.delay      = source.pm_delay;
            punchMove.vibrato    = source.pm_vibrato;
            punchMove.elasticity = source.pm_elasticity;

            punchRotate.enabled    = source.pr_enabled;
            punchRotate.punch      = new Vector3(source.pr_punch_x, source.pr_punch_y, source.pr_punch_z);
            punchRotate.duration   = source.pr_duration;
            punchRotate.delay      = source.pr_delay;
            punchRotate.vibrato    = source.pr_vibrato;
            punchRotate.elasticity = source.pr_elasticity;

            punchScale.enabled    = source.ps_enabled;
            punchScale.punch      = new Vector3(source.ps_punch_x, source.ps_punch_y, source.ps_punch_z);
            punchScale.duration   = source.ps_duration;
            punchScale.delay      = source.ps_delay;
            punchScale.vibrato    = source.ps_vibrato;
            punchScale.elasticity = source.ps_elasticity;

            move.enabled          = source.m_enabled;
            move.to               = new Vector3(source.m_to_x, source.m_to_y, source.m_to_z);
            move.relative         = source.m_relative;
            move.snapping         = source.m_snapping;
            move.duration         = source.m_duration;
            move.delay            = source.m_delay;
            move.ease             = source.m_ease;
            move.reverseAfterTime = source.m_reverseAfterTime;
            move.reverseDuration  = source.m_reverseDuration;
            move.reverseDelay     = source.m_reverseDelay;
            move.reverseEase      = source.m_reverseEase;

            rotate.enabled          = source.r_enabled;
            rotate.to               = new Vector3(source.r_to_x, source.r_to_y, source.r_to_z);
            rotate.relative         = source.r_relative;
            rotate.duration         = source.r_duration;
            rotate.delay            = source.r_delay;
            rotate.ease             = source.r_ease;
            rotate.reverseAfterTime = source.r_reverseAfterTime;
            rotate.reverseDuration  = source.r_reverseDuration;
            rotate.reverseDelay     = source.r_reverseDelay;
            rotate.reverseEase      = source.r_reverseEase;

            scale.enabled          = source.s_enabled;
            scale.to               = new Vector3(source.s_to_x, source.s_to_y, source.s_to_z);
            scale.relative         = source.s_relative;
            scale.duration         = source.s_duration;
            scale.delay            = source.s_delay;
            scale.ease             = source.s_ease;
            scale.reverseAfterTime = source.s_reverseAfterTime;
            scale.reverseDuration  = source.s_reverseDuration;
            scale.reverseDelay     = source.s_reverseDelay;
            scale.reverseEase      = source.s_reverseEase;

            fade.enabled          = source.f_enabled;
            fade.to               = source.f_to;
            fade.relative         = source.f_relative;
            fade.duration         = source.f_duration;
            fade.delay            = source.f_delay;
            fade.ease             = source.f_ease;
            fade.reverseAfterTime = source.f_reverseAfterTime;
            fade.reverseDuration  = source.f_reverseDuration;
            fade.reverseDelay     = source.f_reverseDelay;
            fade.reverseEase      = source.f_reverseEase;
        }