public void SetBrushMode(int newMode) { Painter_BrushMode brushMode = newMode == 0? Painter_BrushMode.DECAL:Painter_BrushMode.PAINT; //Cant set enums for buttons :( string colorText = brushMode == Painter_BrushMode.PAINT?"orange":"purple"; guiTextMode.text = "<b>Mode:</b><color=" + colorText + ">" + brushMode.ToString() + "</color>"; }
////////////////// PUBLIC METHODS ////////////////// public void SetBrushMode(Painter_BrushMode brushMode) //Sets if we are painting or placing decals { mode = brushMode; //TODO change to children var srs = brushCursor.GetComponentsInChildren <SpriteRenderer>(); for (int i = 0; i < srs.Length; ++i) { srs[i].sprite = brushMode == Painter_BrushMode.PAINT ? cursorPaint : cursorDecal; } }
private void InitBrushes() { foreach (Transform transBtn in transPanelBrush) { Button btnBrush = transBtn.GetComponent <Button>(); btnBrush.onClick.AddListener(() => { Image imgBrush = transBtn.GetComponent <Image>(); string strSprite = imgBrush.sprite.name; Painter_BrushMode mode = GetBrushMode(strSprite); painter.SetBrushMode(mode, strSprite); transPanelBrush.gameObject.SetActive(false); }); } }
//FIXME:重写方法 增加参数:sprite名称 public void SetBrushMode(Painter_BrushMode brushMode, string strSprite) { mode = brushMode; if (!myAtlas) { myAtlas = Resources.Load <SpriteAtlas>("MyAtlas"); } if (!myAtlas) { Debug.Log("my atlas is null"); return; } Sprite sprite = myAtlas.GetSprite(strSprite); brushCursor.GetComponent <SpriteRenderer>().sprite = sprite; }
////////////////// PUBLIC METHODS ////////////////// public void SetBrushMode(Painter_BrushMode brushMode) //Sets if we are painting or placing decals { mode = brushMode; brushCursor.GetComponent <SpriteRenderer> ().sprite = brushMode == Painter_BrushMode.PAINT ? cursorPaint : cursorDecal; }
////////////////// PUBLIC METHODS ////////////////// public void SetBrushMode(Painter_BrushMode brushMode) //Sets if we are painting or placing decals { mode = brushMode; }
////////////////// PUBLIC METHODS ////////////////// public void SetBrushMode(Painter_BrushMode brushMode){ //Sets if we are painting or placing decals mode = brushMode; brushCursor.GetComponent<SpriteRenderer> ().sprite = brushMode == Painter_BrushMode.PAINT ? cursorPaint : cursorDecal; }