예제 #1
0
            public SongyPart AddClip(string folderPath, string clipName)
            {
                if (clips == null)
                {
                    clips = new Dictionary <string, SongyClip> ();
                }

                if (clips.ContainsKey(clipName))
                {
                    throw new Exception("SongyPart already has a clip called " + clipName);
                }

                var path = $"{folderPath}\\{clipName}";
                var clip = Resources.Load <AudioClip> (path);

                if (clip == null)
                {
                    throw new Exception($"AudioClip does not exist at given path: {path}");
                }

                var songyClip = new SongyClip(gameObject.AddComponent <AudioSource>(), clip, clipName);

                clips.Add(clipName, songyClip);

                return(this);
            }
예제 #2
0
        float PercentageOfMinimalDistanceToClip(SongyClip clip)
        {
            var clipPosition  = clip.TrackingObject.position;
            var soundPosition = TrackingObject.position;

            var diff = Mathf.Abs(Vector2.Distance(clipPosition, soundPosition));

            return(diff / MinimalDistance * 100);
        }