Exemplo n.º 1
0
 void OnEnable()
 {
     mVertexCount       = -1;
     mLabel             = GetComponent <UILabel>();
     mLabel.onPostFill += OnPostFill;
     mCurrent           = hoverOver;
 }
Exemplo n.º 2
0
 public override void Play(bool forward)
 {
     enabled  = true;
     mCurrent = forward ? hoverOver : hoverOut;
     if (mCurrent.duration != 0f)
     {
         duration = mCurrent.duration;
     }
     base.Play(forward);
 }
Exemplo n.º 3
0
 private void Awake()
 {
     intensityProperties = new AnimationProperties()
     {
         Speed = 1, Timer = 1
     };
     colorProperties = new AnimationProperties()
     {
         Speed = 1, Timer = 1
     };
 }
Exemplo n.º 4
0
 /// <summary>
 /// Invoke control animation.
 /// </summary>
 /// <param name="props">Animation properties.</param>
 private static void AnimateControl(AnimationProperties props)
 {
     if (props.duration > 0)
     {
         const int slide = 0x00040000;
         int       ret   = AnimateWindow(
             props.control.Handle,
             props.duration,
             slide | (int)props.direction | (int)props.action
             );
     }
 }
Exemplo n.º 5
0
        public FFMpegOutput(string destinationFilePath, AnimationProperties properties)
        {
            _process = new Process();
            _process.StartInfo.FileName = "ffmpeg";
            const string argumentsFormat =
                "-y -f rawvideo -pix_fmt bgra -s:v {0}x{1} -r {2:F2} -i pipe:0 -dst_range 0 -pix_fmt yuv422p -crf 0 \"{3}\"";

            _process.StartInfo.Arguments = string.Format(argumentsFormat, properties.Width, properties.Height,
                                                         properties.Fps, destinationFilePath);
            _process.StartInfo.UseShellExecute       = false;
            _process.StartInfo.RedirectStandardInput = true;
            _process.Start();
        }
Exemplo n.º 6
0
 private void Animate(AnimationProperties properties, Action targetAssignment, Action <float> interpolation)
 {
     if (properties.Timer >= 1)
     {
         return;
     }
     properties.Timer += Time.deltaTime * properties.Speed;
     if (properties.Timer >= 1)
     {
         targetAssignment();
     }
     else
     {
         interpolation(properties.Timer);
     }
 }
Exemplo n.º 7
0
        public static int GetElementCount(AnimationProperties property)
        {
            switch (property)
            {
            case AnimationProperties.Translation: return(3);

            case AnimationProperties.EulerRotation: return(3);

            case AnimationProperties.Rotation: return(4);

            case AnimationProperties.Scale: return(3);

            case AnimationProperties.BlendShape: return(1);

            default: throw new NotImplementedException();
            }
        }
Exemplo n.º 8
0
        private async void TryAddNewAnimation(string propertyName, string startValue, string endValue)
        {
            if (String.IsNullOrEmpty(propertyName))
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"TryAddNewAnimation failed - property name is null");
                await Connection.ShowAlert();

                return;
            }

            if (!double.TryParse(startValue, out double startValueDouble))
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"TryAddNewAnimation failed - invalid start value: {startValue}");
                await Connection.ShowAlert();

                return;
            }

            if (!double.TryParse(endValue, out double endValueDouble))
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"TryAddNewAnimation failed - invalid end value: {endValue}");
                await Connection.ShowAlert();

                return;
            }

            if (selectedPhase < 0 || selectedPhase >= Settings.AnimationPhases.Count)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"TryAddNewAnimation failed - invalid selected phase: {selectedPhase}/{Settings.AnimationPhases.Count}");
                await Connection.ShowAlert();

                return;
            }


            // Create a new list of one doesn't already exist
            if (Settings.AnimationPhases[selectedPhase].AnimationActions == null)
            {
                Settings.AnimationPhases[selectedPhase].AnimationActions = new List <PropertyAnimationConfiguration>();
            }

            AnimationProperties property = (AnimationProperties)Enum.Parse(typeof(AnimationProperties), propertyName);

            Settings.AnimationPhases[selectedPhase].AnimationActions.Add(new PropertyAnimationConfiguration(property, startValueDouble, endValueDouble));
            await SaveSettings();
        }
Exemplo n.º 9
0
    void MoveToAnimation(AnimationProperties toAnimation)
    {
        // print($"Changing animation from {currentAnimation.name} to {toAnimation.name} on {transform.parent.gameObject.name} at {Time.realtimeSinceStartup}");
        // print(toAnimation);

        if (animationLoop != null)
        {
            StopCoroutine(animationLoop);
        }

        currentAnimation = toAnimation;
        animationStep    = 0;
        if (canBe3D)
        {
            spriteController.pauseUpdate = !currentAnimation.is3D;
        }
        animationLoop = StartCoroutine(AnimationLoop());
    }
Exemplo n.º 10
0
    void Awake()
    {
        canBe3D        = TryGetComponent <Pseudo3DSpriteController>(out spriteController);
        spriteRenderer = GetComponent <SpriteRenderer>();
        // currentAnimationProperties = new List<Sprite>();
        // currentAnimationProperties3D = new List<Sprite[]>();
        UISpriteLoader.instance.LoadSpriteSheet(spriteName, $"Textures/{spriteName}");
        animations = new List <AnimationProperties>();
        AnimationProperties blank = new AnimationProperties("", null, null, 0, -1, true, false, false, false);

        animations.Add(blank);
        currentAnimation = blank;

        if (!string.IsNullOrEmpty(defaultAnimation.name))
        {
            ChangeAnimation(defaultAnimation.name, defaultAnimation.is3D, defaultAnimation.loopingAnimation, defaultAnimation.FPS, defaultAnimation.interruptableAnimation, defaultAnimation.twoWayAnimation);
        }
    }
Exemplo n.º 11
0
        public static string GetPathName(AnimationProperties property)
        {
            switch (property)
            {
            case AnimationProperties.Translation:
                return(PATH_TRANSLATION);

            case AnimationProperties.EulerRotation:
            case AnimationProperties.Rotation:
                return(PATH_ROTATION);

            case AnimationProperties.Scale:
                return(PATH_SCALE);

            case AnimationProperties.BlendShape:
                return(PATH_WEIGHT);

            default: throw new NotImplementedException();
            }
        }
Exemplo n.º 12
0
    IEnumerator AnimationLoop()
    {
        while (currentAnimation.loopingAnimation ||                                                       // current animation is looping
               (!currentAnimation.loopingAnimation && animationStep < currentAnimation.frameCount) ||     // if its not looping, loop until it ends
               !string.IsNullOrEmpty(nextAnimation.name) && animationStep == currentAnimation.frameCount) // if it is looping, but there's a next animation, wait until current ends

        {
            NextFrame();
            yield return(new WaitForSeconds(1 / currentAnimation.FPS));
        }

        if (!string.IsNullOrEmpty(nextAnimation.name))
        {
            AnimationProperties newAnimation = nextAnimation;
            nextAnimation = animations[0]; // MoveToAnimation cancels this loop, need to set the NextAnimation to blank beforehand
            MoveToAnimation(newAnimation);
        }

        yield break;
    }
Exemplo n.º 13
0
 void Awake()
 {
     mLabel   = GetComponent <UILabel>();
     mCurrent = hoverOver;
 }
Exemplo n.º 14
0
 public void SetProperties(AnimationProperties properties)
 {
     this.properties = properties;
     _startPosition  = transform.position;
     _startRotation  = transform.rotation;
 }
Exemplo n.º 15
0
 public override void Play(bool forward)
 {
     mCurrent = (forward) ? hoverOver : hoverOut;
     base.Play(forward);
 }
 public void CreateAnimation(string animationName, AnimationProperties animationProperty)
 {
     _animationSets.Add(animationName, animationProperty);
 }
Exemplo n.º 17
0
 protected override void Awake()
 {
     mLabel   = GetComponent <UILabel>();
     mCurrent = hoverOver;
     base.Awake();
 }
Exemplo n.º 18
0
    public void ChangeAnimation(string newAnimationName, bool _is3D = false, bool _loopingAnimation = false, float _FPS = -1, bool _interruptableAnimation = true, bool _twoWayAnimation = false)
    {
        if (newAnimationName == currentAnimation.name || newAnimationName == nextAnimation.name || !canBe3D && _is3D)
        {
            return;
        }

        //print($"Current animation {currentAnimation.name}, wanting {newAnimationName}, current animation is interruptable? {currentAnimation.interruptableAnimation} on {transform.parent.gameObject.name}");

        if (string.IsNullOrEmpty(newAnimationName))
        {
            Debug.LogError($"Cannot set animation on {gameObject.name} as it is a null or empty string; resuming previous animation.");
            return;
        }

        bool isCached = false;
        AnimationProperties requestedAnimation = animations[0];

        for (int i = 0; i < animations.Count; i++)
        {
            if (animations[i].name == newAnimationName)
            {
                requestedAnimation = animations[i];
                isCached           = true;
                //print("Cached animation. " + newAnimationName);
                break;
            }
        }

        if (!isCached)
        {
            //print("Not cached; creating sprite list");
            Sprite[]   spriteList      = null;
            Sprite[]   spriteList3D    = null;
            Sprite[][] spriteList3DArr = null;
            int        frameCount;
            float      FPS = _FPS <= 0 ? defaultFPS : _FPS;

            if (_is3D)
            {
                spriteList3D    = UISpriteLoader.instance.GetMatches(spriteName, @"^" + spriteName + "_" + newAnimationName + "\\d_\\d\\d$", true);
                spriteList3DArr = new Sprite[spriteList3D.Length / 5][];

                if (spriteList3D.Length % 5 != 0)
                {
                    Debug.LogError($"Animation \"{newAnimationName}\" has an incorrect amount of sprites for a 3D sprite - requires 5 directional sprites for every frame; resuming previous animation.");
                    return;
                }

                for (int i = 0; i < spriteList3D.Length / 5; i++)
                {
                    Sprite[] arr = new Sprite[5];
                    for (int j = 0; j < 5; j++)
                    {
                        arr[j] = spriteList3D[j + (5 * i)];
                    }
                    spriteList3DArr[i] = arr;
                }

                frameCount = spriteList3D.Length / 5;
            }
            else
            {
                spriteList = UISpriteLoader.instance.GetMatches(spriteName, @"^" + spriteName + "_" + newAnimationName + "\\d$", true);
                frameCount = spriteList.Length;
            }

            if (frameCount == 0)
            {
                Debug.LogWarning($"Animation \"{newAnimationName}\" for {spriteName} doesn't exist or has a discrepancy being marked as 3D when it's not; resuming previous animation.");
                return;
            }

            requestedAnimation = new AnimationProperties(newAnimationName, spriteList, spriteList3DArr, frameCount, FPS, _interruptableAnimation, _is3D, _loopingAnimation, _twoWayAnimation);
            animations.Add(requestedAnimation);
        }

        if (string.IsNullOrEmpty(requestedAnimation.name))
        {
            Debug.LogWarning($"Animation \"{newAnimationName}\" for {spriteName} is invalid.");
            return;
        }

        // if it was a completed uninterruptable animation with no nextAnimation, the AnimationLoop would've already ended so we just move on
        if (currentAnimation.interruptableAnimation || (animationStep >= currentAnimation.frameCount))
        {
            MoveToAnimation(requestedAnimation);
        }
        else
        {
            nextAnimation = requestedAnimation;
        }
    }