-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathColorPicker.cs
More file actions
59 lines (46 loc) · 2 KB
/
Copy pathColorPicker.cs
File metadata and controls
59 lines (46 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace PersistentTrails
{
class ColorPicker : Tac.Window<ColorPicker>
{
private Texture2D colorTexture;
private int ImageWidth = 234;
private int ImageHeight = 199;
private TrackEditWindow editWindow;
public ColorPicker(TrackEditWindow editWindow) : base("Color Picker") {
//Utilities.LoadTexture(ref colorTexture, "ColorPick.png");
this.colorTexture = Utilities.LoadImage("ColorPick.png", ImageWidth, ImageHeight);
this.editWindow = editWindow;
//TODO force window width and height, disallow resize
windowPos = new Rect(350, 30, 220, 120);
SetResizeX(false);
SetResizeY(false);
SetSize(250, 250);
}
protected override void DrawWindowContents(int windowID)
{
//Debug.Log("colorPicker.doGUI");
if (GUILayout.RepeatButton(/*new Rect(10, 10, ImageWidth, ImageHeight),*/ colorTexture))
{
Vector2 pickpos = Event.current.mousePosition;
int aaa = Convert.ToInt32(pickpos.x);
int bbb = Convert.ToInt32(pickpos.y);
Color col = colorTexture.GetPixel(aaa, 41 - bbb);
// "col" is the color value that Unity is returning.
// Here you would do something with this color value, like
// set a model's material tint value to this color to have it change
// colors, etc, etc.
//
// Right now we are just printing the RGBA color values to the Console
//Debug.Log("colorPicked! at " + pickpos.ToString() + ", color = " + pickedColor.ToString());
editWindow.OnColorPicked(col);
SetVisible(false);
}
//GUILayout.EndVertical();
}
}
}