private static void GenerateThreadedCrossfade() { // generates crossfade frames in queued multi-threaded order // lightens the load on the update function of the animator while (!s_shutDownThreads) { try { MeshAnimator ma = null; while ((ma = DequeueAnimatorForCrossfade()) != null) { if (ma.currentCrossFade.isFading) { ma.GenerateCrossfadeFrame(); System.Threading.Thread.Sleep(0); } } } catch { } int count = 0; do { lock (s_crossfadeAnimators) { count = s_crossfadeAnimators.Count; } if (count == 0) { System.Threading.Thread.Sleep(1); } }while (count == 0); } }
public static void AddAnimator(MeshAnimator animator) { if (Instance) { mAnimators.Add(animator); } }
private static void EnqueueAnimatorForCrossfade(MeshAnimator animator) { #if THREADS_ENABLED lock (crossfadeAnimators) crossfadeAnimators.Enqueue(animator); crossfadeWaitHandle.Set(); #endif }
/// <summary> /// Enqueue a MeshAnimator for crossfading /// </summary> private static void EnqueueAnimatorForCrossfade(MeshAnimator animator) { #if THREADS_ENABLED lock (s_crossfadeAnimators) { s_crossfadeAnimators.Enqueue(animator); } #endif }
private void Update() { float t = Time.time; int c = mAnimators.Count; for (int i = 0; i < c; i++) { MeshAnimator animator = mAnimators[i]; if (t >= animator.nextTick) { animator.UpdateTick(t); } } }
private void UpdateTick(float time) { int c = mAnimators.Count; for (int i = 0; i < c; i++) { MeshAnimator animator = mAnimators[i]; if (time >= animator.nextTick) { // try // { animator.UpdateTick(time); // } // catch (System.Exception ex) // { // Debug.LogException(ex); // } } } }
void SpawnCrowd() { foreach (var obj in spawnedObjects) { if (obj) { Destroy(obj); } } spawnedObjects.Clear(); List <int> occupiedSpaces = new List <int>(); for (int i = 0; i < sizeOfCrowd; i++) { if (i > transform.childCount) { occupiedSpaces.Clear(); } int space = Random.Range(0, transform.childCount); while (occupiedSpaces.Contains(space)) { space = Random.Range(0, transform.childCount); } var g = (GameObject)GameObject.Instantiate(options[selectedOption]); g.transform.position = transform.GetChild(space).position + new Vector3(Random.value, 0, Random.value) * 2; g.transform.LookAt(transform, Vector3.up); if (g.GetComponent <Animator>()) { g.GetComponent <Animator>().speed = Random.Range(0.9f, 1.1f); g.GetComponent <Animator>().SetInteger("Anim", Random.Range(0, 6)); } else if (g.GetComponent <MeshAnimator>()) { MeshAnimator ma = g.GetComponent <MeshAnimator>(); ma.defaultAnimation = ma.animations[Random.Range(0, ma.animations.Length)]; ma.speed = Random.Range(0.9f, 1.1f); } spawnedObjects.Add(g); } }
private static void GenerateThreadedCrossfade() { // generates crossfade frames in queued multi-threaded order // lightens the load on the update function of the animator while (!shutDownThreads) { try { MeshAnimator ma = null; while ((ma = DequeueAnimatorForCrossfade()) != null) { if (ma.currentCrossFade.isFading) { ma.GenerateCrossfadeFrame(); } } } catch { } crossfadeWaitHandle.WaitOne(); } }
private void Update() { float t = Time.time; int c = mAnimators.Count; for (int i = 0; i < c; i++) { MeshAnimator animator = mAnimators[i]; if (t >= animator.nextTick) { try { animator.UpdateTick(t); } catch (System.Exception ex) { Debug.LogException(ex); } } } }
public static void RemoveAnimator(MeshAnimator animator) { mAnimators.Remove(animator); }
private void Start() { _meshAnimator = GetComponent <FSG.MeshAnimator.MeshAnimator>(); _meshRenderer = GetComponent <MeshRenderer>(); }