public override void ExtendedGUI() { ColorDriver colorDriver = (ColorDriver)target; EditorGUILayout.PropertyField(colorModeProp, new GUIContent("Color Mode", "Allows you to choose how the Gradient color is applied.")); if (colorDriver.colorMode != ColorMode.Frequency) { EditorGUILayout.PropertyField(stationaryToggleProp, new GUIContent("Stationary", "Check this if a Segmented Levels shape was built with the SpectrumBuilder.")); } EditorGUILayout.PropertyField(indexProp, new GUIContent("Material Index", "The index to a material for the attached mesh.")); EditorGUILayout.PropertyField(mainColorProp, new GUIContent("Main Color", "Used to color object by magnitude or frequency.")); EditorGUILayout.PropertyField(restingColorProp, new GUIContent("Resting Color", "Used by segmented levels built with the SpectrumBuilder.")); /* * if (colorDriver.stationaryToggle) * { * EditorGUILayout.PropertyField(restingColorProp); * } * else * { * if (colorDriver.colorMode == ColorMode.Frequency) * { * EditorGUILayout.PropertyField(restingColorProp); * } * } */ }
public VectorShape(ColorDriver sharedDriver, Transform transform, bool isLine) { vertexElements = new VertexElement[transform.childCount]; Level level; VertexElementColor vertexColor; ColorDriver colorDriver; int i = 0; foreach (Transform levelTransform in transform) { level = levelTransform.GetComponent <Level>(); if ((vertexColor = levelTransform.GetComponent <VertexElementColor>()) == null) { vertexColor = levelTransform.gameObject.AddComponent <VertexElementColor>(); } if ((colorDriver = levelTransform.GetComponent <ColorDriver>()) == null) { colorDriver = levelTransform.gameObject.AddComponent <ColorDriver>(); } colorDriver.sharedDriver = sharedDriver; if (isLine) { vertexElements[i] = new VertexElement(level, levelTransform.localPosition, Vector3.Normalize(Vector3.up), Color.white, Color.black); } else { vertexElements[i] = new VertexElement(level, levelTransform.localPosition, Vector3.Normalize(levelTransform.localPosition), Color.white, Color.black); } vertexColor.index = i++; vertexColor.vectorShape = this; } }
protected override void DoLevel() { ColorDriver colorDriver = (sharedDriver != null) ? (ColorDriver)sharedDriver : this; int i = 0; Material material = null; float v = 0.0f; if (!ps && !vertexColor) { i = Mathf.Min(colorDriver.materialIndex, materials.Length - 1); material = materials[i]; } float level = LevelScalar(); Color mainColor = Color.white; Color restingColor = Color.black; if (colorDriver.stationaryToggle && !vertexColor) { if (colorDriver.colorMode == ColorMode.Frequency) { v = base.level.linearizedFrequency; } else { v = base.level.normalizedLevel; } if (level >= base.level.normalizedLevel) { mainColor = Color.Lerp(colorDriver.restingColor.Evaluate(v), colorDriver.mainColor.Evaluate(v), level); } else { mainColor = colorDriver.restingColor.Evaluate(v); } } else { switch (colorDriver.colorMode) { case ColorMode.Magnitude: mainColor = colorDriver.mainColor.Evaluate(level); restingColor = colorDriver.restingColor.Evaluate(level); break; case ColorMode.Frequency: v = base.level.linearizedFrequency; if (vertexColor) { mainColor = colorDriver.mainColor.Evaluate(v); restingColor = colorDriver.restingColor.Evaluate(v); } else { mainColor = Color.Lerp(colorDriver.restingColor.Evaluate(v), colorDriver.mainColor.Evaluate(v), level); } break; } } if (ps) { ParticleSystem.MainModule module = ps.main; module.startColor = mainColor; } else if (material) { material.SetColor(colorID, mainColor); } else if (vertexColor) { vertexColor.mainColor = mainColor; vertexColor.restingColor = restingColor; } }