//Hint Look at Color class in Unity SDK //Setup Collider Trigger to send the color of this object to the Brush Handler private void OnTriggerEnter(Collider other) { // Find the brush in scene BrushHandler brushHandler = (BrushHandler)FindObjectOfType(typeof(BrushHandler)); // If there is a brush, set our brush's color with the setBrushColor Method if (brushHandler) { other.gameObject.GetComponent <BrushHandler>().setBrushColor(colorSelector); } }
public void Draw() { //find the brush controller using findobject of type brushHandler = (BrushHandler)FindObjectOfType(typeof(BrushHandler)); //see which color is currently applied in the brush Color brushHandlerColor = brushHandler.returnCurrentBrushColor(); //update the material of your brush to that color brushHandler.GetComponent <MeshRenderer>().material.color = brushHandlerColor; //draw our brush here using instantiating Instantiate(brushHandler, transform.position, transform.rotation); }