//Recolors the particles private void ColorParticles() { if (Settings.COLOR) { Color c; Renderer rend; for (int i = 0, len = ElectronCount; i < len; i++) { rend = (particles[i] as Electron).Render; if (i < 2) { c = BlockTypeUtil.ColorFromBlock(BlockType.sBlock); } else if (i < 8) { c = BlockTypeUtil.ColorFromBlock(BlockType.pBlock); } else if (i < 18) { c = BlockTypeUtil.ColorFromBlock(BlockType.dBlock); } else { c = BlockTypeUtil.ColorFromBlock(BlockType.fBlock); } rend.material.SetColor("_Color", c); rend.material.SetColor("_EmissionColor", c / 4); } } }
private void Awake() { Image[] images = GetComponentsInChildren <Image>(); //Text[] texts = GetComponentsInChildren<Text>(); images[0].color = BlockTypeUtil.ColorFromBlock(BlockType.sBlock); images[1].color = BlockTypeUtil.ColorFromBlock(BlockType.pBlock); images[2].color = BlockTypeUtil.ColorFromBlock(BlockType.dBlock); images[3].color = BlockTypeUtil.ColorFromBlock(BlockType.fBlock); }
/// <summary> /// Color the object based on l and ms /// </summary> private void AdjustColor(GameObject obj, int l, int ms) { if (obj == null) { return; //exit out to avoid no object error } Renderer[] renderers = obj.GetComponentsInChildren <Renderer>(); //get all the renderers Color color = BlockTypeUtil.ColorFromBlock((BlockType)l); //get color from (l) if (Settings.MATERIAL == SettingsMaterial.Transparent) //tone down transparency { color = Color.Lerp(color, new Color(1, 1, 1), 0.8f); color.a = 0.3f; } //if (ms == -1) { color.r /= 2; color.g /= 2; color.b /= 2; } //tone down for one electron in shell if (ms == -1) //tone down for one electron in shell { color -= new Color(0.3f, 0.3f, 0.3f, 0f); } foreach (Renderer r in renderers) { r.material.SetColor("_Color", color); } }
private void Awake() { Text[] texts = GetComponentsInChildren <Text>(); buttons = new Button[118]; //loop over the text elements in the table for (int t = 0; t < texts.Length; t += 2) { int i = t / 2; //index every 2 elements -> (number + abb) //get proton count from index int protonCount = -1; if (i < 56) { protonCount = i + 1; } //elements up to Lathanoids else if (i > 56 && i < 74) { protonCount = i + 15; } //elements after Lathanoids and before Actinoids else if (i > 74 && i < 90) { protonCount = i + 29; } //elements after Actinoids and before END else if (i >= 90 && i < 105) { protonCount = i - 33; } //Lathanoids else if (i >= 105 && i < 120) { protonCount = i - 16; } //Actinoids Element element = Elements.GetElement(protonCount); //get bound element if (element != null) { //Hook up button to show the element data Button b = texts[t + 1].GetComponentInParent <Button>(); b.onClick.AddListener(() => OnElementSelect?.Invoke(protonCount)); buttons[protonCount - 1] = b; switch (displayType) //see enum for description { case PeriodicTableDisplayType.BlockCount: texts[t].text = ""; texts[t + 1].text = BlockTypeUtil.BlockTypeToString[element.Block]; b.image.color = BlockTypeUtil.ColorFromBlock(element.Block); break; case PeriodicTableDisplayType.Block: texts[t].text = protonCount.ToString(); texts[t + 1].text = element.Abbreviation; b.image.color = BlockTypeUtil.ColorFromBlock(element.Block); break; case PeriodicTableDisplayType.Type: texts[t].text = protonCount.ToString(); texts[t + 1].text = element.Abbreviation; b.image.color = ElementTypeUtil.ColorFromType(element.Type); break; case PeriodicTableDisplayType.NoNum: texts[t].text = ""; texts[t + 1].text = element.Abbreviation; b.image.color = ElementTypeUtil.ColorFromType(element.Type); break; } } } if (atom) { //update the atom to match selected element OnElementSelect += atom.ForceToCommon; } }