Ejemplo n.º 1
0
        /// <summary>
        /// initialize wipe setting and create brush sprite and particle if available
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="wipeTransform"></param>
        public void Init(WipeSettings settings, Transform wipeTransform)
        {
            paintFinished = false;
            wipeSettings  = settings;

            //Get compute shader from WipeManager
            computeShader = settings.computeShader;
            //Get ID of function from Compute Shader to call
            kernelHandle = computeShader.FindKernel("CSMain");

            onWipeEventHandlers = wipeTransform.GetComponentsInChildren <IOnWipeEventHandler>(); //use wipemanager

            //Get WipeBrush texture from editor
            Texture2D newTexture = wipeSettings.wipeBrush.texture;

            //Set size of WipeBrush based on "brushSize" from Editor
            Vector2 newSize = new Vector2(wipeSettings.brushSize * ((float)newTexture.width / newTexture.height), wipeSettings.brushSize);

            //Get WipeBrush texture with "brushSize"
            newTexture = ScaleTexture(newTexture, (int)newSize.x, (int)newSize.y);

            //Create sprite from WipeBrush texture
            wipeBrushSprite = Sprite.Create(newTexture, new Rect(0, 0, newTexture.width, newTexture.height), new Vector2(0.5f, 0.5f), 2000);
            wipeBrushSprite.texture.Apply();

            //Get all pixels from WipeBrush image
            brushColorDefault = wipeBrushSprite.texture.GetPixels();
        }
Ejemplo n.º 2
0
 private void Awake()
 {
     if (!Application.isPlaying && wipeSettings == null)
     {
         wipeSettings = new WipeSettings();
     }
 }