Skip to content

Instantly share code, notes, and snippets.

@dentedpixel
Created March 4, 2016 16:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dentedpixel/587d21be0654408b8c53 to your computer and use it in GitHub Desktop.
Save dentedpixel/587d21be0654408b8c53 to your computer and use it in GitHub Desktop.
An example of showing how to do a LeanTwee.moveSpline with better performance.
using UnityEngine;
using System.Collections;
public class EngineStressTest1 : MonoBehaviour {
private int animateCount = 6000;
private GameObject[] cubes;
private LTSpline[] splines;
void Awake(){
LeanTween.init( animateCount*5 );
int iter = 0;
int side = System.Convert.ToInt32( Mathf.Pow( animateCount*1.0f, 1.0f/3.0f ) );
Vector3 p;
cubes = new GameObject[ side*side*side ];
splines = new LTSpline[ side*side*side ];
for(int i = 0; i < side; i++){
for(int j = 0; j < side; j++){
for( int k = 0; k < side; k++){
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
Destroy( cube.GetComponent( typeof(BoxCollider) ) as Component );
p = new Vector3(i*3,j*3,k*3);
cube.transform.position = p;
//cube.GetComponent<Renderer>().enabled = false;
cube.name = "cube"+iter;
cubes[iter] = cube;
splines[iter] = new LTSpline( new Vector3[] {new Vector3(-1f,0f,0f), new Vector3(-1f,0f,0f), new Vector3(0f,0f,0f), new Vector3(4f,0f,0f), new Vector3(20f,0f,0f), new Vector3(20f,0f,0f)} );
iter++;
}
}
}
}
void Update(){
if (Input.GetKeyDown(KeyCode.T))
{
Debug.Log("Starting");
for(int i = 0; i < cubes.Length; i++){
float delay = 0f;//iter*1.0f/cubes.Length;
LeanTween.move(cubes[i], splines[i], 1.0f ).setEase( LeanTweenType.easeInOutQuad ).setLoopType(LeanTweenType.pingPong).setRepeat(-1).setDelay(delay);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment