Exemple #1
0
        private void Animator_NodeReached(object sender, NodeReachedEventArgs e)
        {
            if (!Application.isPlaying)
            {
                return;
            }

            // If audio is playing, record timestamp.
            if (AudioSource.isPlaying)
            {
                AudioNodeTimestamps[e.NodeIndex] = AudioSource.time;
            }
        }
Exemple #2
0
        private void Animator_JumpedToNode(
            object sender,
            NodeReachedEventArgs e)
        {
            if (!Application.isPlaying)
            {
                return;
            }

            // Return if audio timestamp for this node was not recorded.
            if (!AudioNodeTimestamps.ContainsKey(e.NodeIndex))
            {
                return;
            }

            AudioSource.time = AudioNodeTimestamps[e.NodeIndex];
        }
Exemple #3
0
        private void Animator_NodeReached(
            object sender,
            NodeReachedEventArgs arg)
        {
            // Get event slot.
            var nodeEvent = NodeEventSlots[arg.NodeIndex];

            // Return if source GO was not specified in the event slot.
            if (nodeEvent.SourceGO == null)
            {
                return;
            }
            // Get method metadata.
            var methodInfo = nodeEvent.SourceCo.GetType()
                             .GetMethod(nodeEvent.SourceMethodName);

            // Return if method info couldn't be loaded.
            if (methodInfo == null)
            {
                return;
            }
            // Get method parameters.
            var methodParams = methodInfo.GetParameters();

            // Method has no parameters.
            if (methodParams.Length == 0)
            {
                // Invoke method.
                methodInfo.Invoke(nodeEvent.SourceCo, null);
            }
            // Method has one parameter.
            else if (methodParams.Length == 1)
            {
                // Return if the parameter is not a string.
                if (methodParams[0].ParameterType.Name != "String")
                {
                    return;
                }
                // Create string parameter argument.
                var stringParam = new object[] { nodeEvent.MethodArg };
                // Invoke method with string parameter.
                methodInfo.Invoke(nodeEvent.SourceCo, stringParam);
            }
        }
        private void Animator_JumpedToNode(
            object sender,
            NodeReachedEventArgs e)
        {
            if (!Application.isPlaying)
            {
                return;
            }

            // For each target animator component..
            for (var i = 0; i < TargetComponents.Count; i++)
            {
                // Return if timestamp for this node was not recorded.
                if (!NodeTimestamps[i].ContainsKey(e.NodeIndex))
                {
                    continue;
                }

                // Update animation time.
                TargetComponents[i].AnimationTime =
                    NodeTimestamps[i][e.NodeIndex];
            }
        }
        private void Animator_NodeReached(
            object sender,
            NodeReachedEventArgs e)
        {
            if (!Application.isPlaying)
            {
                return;
            }

            // For each target animator component..
            for (var i = 0; i < TargetComponents.Count; i++)
            {
                // Don't record when source component is not playing.
                if (!TargetComponents[i].IsPlaying)
                {
                    return;
                }

                // Remember current timestamp.
                NodeTimestamps[i][e.NodeIndex] =
                    TargetComponents[i].AnimationTime;
            }
        }