void Start() { tex = DrawingArea.GetComponent <SpriteRenderer>().sprite.texture; //Debug.Log(tex.height); //Debug.Log(tex.width); //Debug.Log(obj); initalX = (int)(100 * (gameObject.transform.localPosition.x) - offsetVector.x - 0.5 * collide.size.x); //add 1/2 width of image to get it to be centered @ top left corner initalY = (-1 * (int)(100 * (gameObject.transform.localPosition.y) + offsetVector.y - 0.5 * collide.size.y)); //Debug.Log("Y: " + initalY.ToString()); //subtact 1/2 length of image to get it to be centered @ top left corner width = (int)(100 * collide.size.x); height = (int)(100 * collide.size.y); //tex = DrawingArea.GetComponent<SpriteRenderer>().sprite.texture.SubTexture(new Rect(initalX, initalY, width, height)); //tex = new Texture2D(width, height); //Texture2D SrcText = DrawingArea.GetComponent<SpriteRenderer>().sprite.texture; //Graphics.CopyTexture(SrcText, 0, 0, initalX, initalY, width, height, tex, 0, 0, 0, 0); //tex.Apply(); //SrcText.Apply(); drawSurf = DrawingArea.GetComponent <FreeDraw.DrawingSettings>(); //Debug.Log(tex); start = AverageColor(tex, initalX, initalY, width, height); }
IEnumerator loadColourChange(FreeDraw.DrawingSettings brush) { yield return(new WaitForSeconds(0.5f)); if (setting_colour) { setting_colour = true; lerp_progress = 0; new_colour = brush.GetBrushColour(); Debug.Log("new_colour set"); } }
private void OnTriggerEnter(Collider other) { if (other.transform.tag == "Brush") { FreeDraw.DrawingSettings brush = other.transform.parent.gameObject.GetComponent <FreeDraw.DrawingSettings>(); if (brush.is_clean) { brush.SetBrushColour(colour); } else { setting_colour = true; StartCoroutine(loadColourChange(brush)); } } }