public void ShowHide_Outline(bool vChoice) { //get all outlines child if (MasterOutline != null) { Outline[] Outlines = MasterOutline.GetComponentsInChildren <Outline> (); //if we want to ONlY have this sprite and not all the sub component to have a outline, we just get the main sprite. if (!OutlineAllChild) { Outlines = new Outline[] { GetComponent <Outline>() } } ; //add/remove them all foreach (Outline vCurOutline in Outlines) { if (vChoice) { vOutlineManager.AddOutline(vCurOutline); } else { vOutlineManager.RemoveOutline(vCurOutline); } } } //save the preference CanShow = vChoice; } void OnDisable() { vOutlineManager.RemoveOutline(this); } //ONLY work on mouseover type void OnMouseOver() { if (vOutlineType == OutlineType.MouseOver) { ShowHide_Outline(true); } else if (vOutlineType == OutlineType.Click && Input.GetMouseButtonDown(0)) { //show/hide this outline ShowHide_Outline(!CanShow); } } void OnMouseExit() { if (vOutlineType == OutlineType.MouseOver) { ShowHide_Outline(false); } } }
public void ShowHide_Outline(bool vChoice) { //get all outlines child if (MasterOutline != null) { Outline[] Outlines = MasterOutline.GetComponentsInChildren <Outline> (); //add/remove them all foreach (Outline vCurOutline in Outlines) { if (vChoice) { vOutlineManager.AddOutline(vCurOutline); } else { vOutlineManager.RemoveOutline(vCurOutline); } } } //save the preference CanShow = vChoice; }
public void ShowHide_Outline(bool vChoice) { //get all outlines child if (MasterOutline != null) { Outline[] Outlines = MasterOutline.GetComponentsInChildren <Outline>(); //if we want to ONlY have this sprite and not all the sub component to have a outline, we just get the main sprite. if (!OutlineAllChild) { Outlines = new Outline[] { GetComponent <Outline>() } } ; //add/remove them all foreach (Outline vCurOutline in Outlines) { if (vChoice) { vOutlineManager.AddOutline(vCurOutline); } else { vOutlineManager.RemoveOutline(vCurOutline); } } } //save the preference CanShow = vChoice; } //void OnDisable() //{ // vOutlineManager.RemoveOutline(this); //} //ONLY work on mouseover type void OnMouseOver() { if (vOutlineType == OutlineType.MouseOver) { ShowHide_Outline(true); } else if (vOutlineType == OutlineType.Click && Input.GetMouseButtonDown(0)) { //show/hide this outline ShowHide_Outline(!CanShow); } } void OnMouseExit() { if (vOutlineType == OutlineType.MouseOver) { ShowHide_Outline(false); } } void Update() { ShowHide_Outline(ShowOutline); //float range = 2.0f; ////float timer = 500; //playerController[] cars = GameObject.FindObjectsOfType<playerController>(); //foreach (playerController car in cars) //{ // if (Vector2.Distance(car.transform.position, this.transform.position) <= range) // { // if (car.getPlayerNum() == 1) // { // color = 0;//set color to yellow // } // else if (car.getPlayerNum() == 2) // { // color = 1;//set color to green // } // else if (car.getPlayerNum() == 3) // { // color = 2;//set color to pink // } // else if (car.getPlayerNum() == 4) // { // color = 3;//set color to blue // } // } //} }