Example #1
0
    // Start is called before the first frame update
    public void Start()
    {
        drawing_script      = FindObjectOfType <sc_drawing_handler>();
        drawing_canvas      = sc_canvas.instance.drawing_canvas;
        color_picker_canvas = sc_canvas.instance.color_picker_canvas;

        //set to default color
        Color.RGBToHSV(drawing_script.default_color, out float h, out float s, out float v);
        current_color = new Vector3(h, s, v);
        slider_color  = Resources.Load("Materials/m_slider") as Material;
        slider_color.SetVector("_HSVColor", new Vector4(h, s, v, 1));

        //init recently used
        recently_selected     = new Button[num_saved_colors];
        recently_selected_obj = new GameObject[num_saved_colors];

        RectTransform container   = recently_selected_container.GetComponent <RectTransform>();
        int           rect_width  = (int)(container.rect.width * color_picker_canvas.GetComponent <Canvas>().scaleFactor);
        int           rect_height = (int)(container.rect.height * color_picker_canvas.GetComponent <Canvas>().scaleFactor);
        int           intervalX   = rect_width / (num_saved_colors + 1);
        int           intervalY   = -rect_height / 8;

        for (int i = 0; i < num_saved_colors; i++)
        {
            GameObject o = Instantiate(button_prefab, recently_selected_container.transform);
            o.transform.localPosition = new Vector3(-(rect_width / 2 - intervalX) + intervalX * i, intervalY, 0);
            //o.transform.Translate(new Vector3(intervalX + intervalX * i, intervalY, 0));
            Button b = o.transform.Find("Button").GetComponent <Button>();
            recently_selected[i]     = b;
            recently_selected_obj[i] = o;
            //Set on click listener
            b.onClick.AddListener(delegate() { recent_color_selected(b); });
            o.SetActive(false);
        }
    }
Example #2
0
    private sc_tool[] tools = { new sc_tool_brush(), new sc_tool_fill() };  // list of all tools


    private void Awake()
    {
        // avoid doubeling of this script
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            instance = this;
        }

        //initialize tools
        foreach (sc_tool t in tools)
        {
            t.initialize();
        }

        GameObject obj = GameObject.FindGameObjectWithTag("paintable");

        // set component mask
        component_mask = (Texture2D)obj.GetComponent <Renderer>().material.GetTexture("_ComponentMask");

        // setup canvas
        loadTexture(obj.GetComponent <Renderer>().material.mainTexture, out canvas);

        // set object texture as canvas
        obj.GetComponent <Renderer>().material.mainTexture = canvas;
    }
Example #3
0
    private sc_tool[] tools = { new sc_tool_brush(), new sc_tool_fill() }; // list of all tools


    private void Awake()
    {
        active = false;

        // avoid doubeling of this script
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            instance = this;
        }

        //initialize tools
        foreach (sc_tool t in tools)
        {
            t.initialize();
        }

        GameObject obj = GameObject.FindGameObjectWithTag("paintable");

        // set component mask
        component_mask = (Texture2D)obj.GetComponent <Renderer>().material.GetTexture("_ComponentMask");

        Camera cam = FindObjectOfType <Camera>();

        if (!((cam.pixelWidth == 1600 && cam.pixelHeight == 2560) || (cam.pixelWidth == 1536 && cam.pixelHeight == 2048)))
        {
            Debug.LogError("Wrong resolution. This app only works with 1600x2560 or 1536x2048");
            return;
        }

        //load uv textures
        string path = "Textures/uv_" + cam.pixelWidth + "x" + cam.pixelHeight;

        byte[] data = (Resources.Load(path) as TextAsset).bytes;

        uvImage = new Texture2D(cam.pixelWidth, cam.pixelHeight, TextureFormat.RGBAFloat, false);
        uvImage.LoadRawTextureData(data);
        uvImage.Apply();

        /*uvImage = new RenderTexture(tex.width, tex.height, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Default);
         * Graphics.Blit(tex, uvImage);*/

        // set default color
        default_color = new Color(220f / 255f, 160f / 255f, 90f / 255f, 1);
    }
Example #4
0
    private string info_name = "", info_age = "", info_sex = ""; //infos added while saving

    // Start is called before the first frame update
    public void Start()
    {
        color_picker_canvas = sc_canvas.instance.color_picker_canvas;
        gallery_canvas      = sc_canvas.instance.gallery_canvas;
        drawing_canvas      = sc_canvas.instance.drawing_canvas;
        drawing_script      = FindObjectOfType <sc_drawing_handler>();
        gallery_loader      = FindObjectOfType <sc_gallery_loader>();
        color_picker        = FindObjectOfType <sc_color_picker_ui>();
        gallery_ui          = FindObjectOfType <sc_gallery_ui>();
        name_input          = save_dialog.transform.Find("NameInput").GetComponent <InputField>();
        age_input           = save_dialog.transform.Find("AgeInput").GetComponent <InputField>();
        sex_input           = save_dialog.transform.Find("SexDropdown").GetComponent <Dropdown>();
        brush_button.transform.Find("BrushIcon").Find("BrushHead").GetComponent <Image>().color        = drawing_script.default_color;
        bucket_button.transform.Find("BucketIcon").Find("BucketContents").GetComponent <Image>().color = drawing_script.default_color;
        drawing_script.drawing_color = drawing_script.default_color;

        brush_size_slider.GetComponent <Slider>().value = (drawing_script.get_tool("brush") as sc_tool_brush).brush_size;
    }
Example #5
0
    private sc_drawing_handler drawing_script;  // The script responsible for all the drawing

    // Start is called before the first frame update
    void Start()
    {
        // initializing draw script
        drawing_script = FindObjectOfType <sc_drawing_handler>();
    }
Example #6
0
 // Start is called before the first frame update
 private void Start()
 {
     slider_color   = Resources.Load("Materials/m_slider") as Material;
     drawing_script = FindObjectOfType <sc_drawing_handler>();
 }