void Start() { /* * Get Drink Type * Set Labels * Set Liquid Color */ pd = GetComponent <PourDetector>(); LiquidType contents = pd.liqourType; TextMeshPro[] labels = GetComponentsInChildren <TextMeshPro>(); foreach (TextMeshPro textMeshPro in labels) { textMeshPro.text = contents.ToString("G"); } Color liquidColor = LiquidColour.getLiquidColor(contents) * (1f / 255f); liquidColor.a = 1; Renderer liquidRenderer = gameObject.GetComponentInChildren <Wobble>().gameObject.GetComponent <Renderer>(); liquidRenderer.material.SetColor("_Tint", liquidColor); liquidRenderer.material.SetColor("_TopColor", liquidColor + new Color(0.1f, 0.1f, 0.1f, 1)); liquidRenderer.material.SetColor("_FoamColor", liquidColor + new Color(0.1f, 0.1f, 0.1f, 1)); var particleSystemMainModule = GetComponent <ParticleSystem>().main; particleSystemMainModule.startColor = liquidColor; position = transform.position; orientation = transform.rotation.eulerAngles; }
public override void OnInspectorGUI() { var PourDetector = target as PourDetector; // Draw the default inspector DrawDefaultInspector(); liqourIndex = (int)PourDetector.liqourType; liqourIndex = EditorGUILayout.Popup(liqourIndex, liqourStrings); if (PourDetector.liqourType != (LiquidType)liqourIndex) { // Update the selected choice in the underlying object LiquidType liquidType = (LiquidType)liqourIndex; PourDetector.liqourType = liquidType; PourDetector.liquidColor = LiquidColour.getLiquidColor(liquidType); //PourDetector.UpdateLiqourType((LiquidType)liqourIndex); Debug.Log("set " + (LiquidType)liqourIndex); // Save the changes back to the object EditorUtility.SetDirty(target); } }