public IEnumerator Compute(GraphLayoutParameters settings) { if (!position.Any()) { yield break; } this.settings = settings; int iterationId = 0; while (iterationId++ < settings.numIterations) { float maxMove = settings.initalMaxMove * (1 - ((float)iterationId / (float)settings.numIterations)); RunIteration(maxMove); yield return(position); } }
void ShowGraphLayoutParams(GraphLayoutParameters parameters) { EditorGUILayout.Space(); foldLayoutSettings = EditorGUILayout.Foldout(foldLayoutSettings, "Graph layout settings"); if (foldLayoutSettings) { GUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.BeginVertical(); parameters.posInitRange = EditorGUILayout.FloatField("Init positioning range", parameters.posInitRange); parameters.idealDistance = EditorGUILayout.FloatField("Ideal vertex spacing", parameters.idealDistance); parameters.initalMaxMove = EditorGUILayout.FloatField("Inital max move", parameters.initalMaxMove); parameters.numIterations = EditorGUILayout.IntField("Number of iterations", parameters.numIterations); parameters.gravityStrength = EditorGUILayout.FloatField("Gravity strength", parameters.gravityStrength); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } }