Here are the examples of the csharp api System.Func.Invoke(Vector4) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
19
Source : TrackballUIDrawer.cs
with MIT License
from idovelemon
with MIT License
from idovelemon
void DrawWheel(ref Vector4 value, bool overrideState)
{
var wheelRect = GUILayoutUtility.GetAspectRect(1f);
float size = wheelRect.width;
float hsize = size / 2f;
float radius = 0.38f * size;
Vector3 hsv;
Color.RGBToHSV(value, out hsv.x, out hsv.y, out hsv.z);
float offset = value.w;
// Thumb
var thumbPos = Vector2.zero;
float theta = hsv.x * (Mathf.PI * 2f);
thumbPos.x = Mathf.Cos(theta + (Mathf.PI / 2f));
thumbPos.y = Mathf.Sin(theta - (Mathf.PI / 2f));
thumbPos *= hsv.y * radius;
// Draw the wheel
if (Event.current.type == EventType.Repaint)
{
// Style init
if (s_WheelThumb == null)
{
s_WheelThumb = new GUIStyle("ColorPicker2DThumb");
s_WheelThumbSize = new Vector2(
!Mathf.Approximately(s_WheelThumb.fixedWidth, 0f) ? s_WheelThumb.fixedWidth : s_WheelThumb.padding.horizontal,
!Mathf.Approximately(s_WheelThumb.fixedHeight, 0f) ? s_WheelThumb.fixedHeight : s_WheelThumb.padding.vertical
);
}
// Retina support
float scale = EditorGUIUtility.pixelsPerPoint;
// Wheel texture
var oldRT = RenderTexture.active;
var rt = RenderTexture.GetTemporary((int)(size * scale), (int)(size * scale), 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
s_Material.SetFloat("_Offset", offset);
s_Material.SetFloat("_DisabledState", overrideState && GUI.enabled ? 1f : 0.5f);
s_Material.SetVector("_Resolution", new Vector2(size * scale, size * scale / 2f));
Graphics.Blit(null, rt, s_Material, EditorGUIUtility.isProSkin ? 0 : 1);
RenderTexture.active = oldRT;
GUI.DrawTexture(wheelRect, rt);
RenderTexture.ReleaseTemporary(rt);
var thumbSize = s_WheelThumbSize;
var thumbSizeH = thumbSize / 2f;
s_WheelThumb.Draw(new Rect(wheelRect.x + hsize + thumbPos.x - thumbSizeH.x, wheelRect.y + hsize + thumbPos.y - thumbSizeH.y, thumbSize.x, thumbSize.y), false, false, false, false);
}
// Input
var bounds = wheelRect;
bounds.x += hsize - radius;
bounds.y += hsize - radius;
bounds.width = bounds.height = radius * 2f;
hsv = GetInput(bounds, hsv, thumbPos, radius);
value = Color.HSVToRGB(hsv.x, hsv.y, 1f);
value.w = offset;
// Offset
var sliderRect = GUILayoutUtility.GetRect(1f, 17f);
float padding = sliderRect.width * 0.05f; // 5% padding
sliderRect.xMin += padding;
sliderRect.xMax -= padding;
value.w = GUI.HorizontalSlider(sliderRect, value.w, -1f, 1f);
if (m_ComputeFunc == null)
return;
// Values
var displayValue = m_ComputeFunc(value);
using (new EditorGUI.DisabledGroupScope(true))
{
var valuesRect = GUILayoutUtility.GetRect(1f, 17f);
valuesRect.width /= 3f;
GUI.Label(valuesRect, displayValue.x.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
valuesRect.x += valuesRect.width;
GUI.Label(valuesRect, displayValue.y.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
valuesRect.x += valuesRect.width;
GUI.Label(valuesRect, displayValue.z.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
valuesRect.x += valuesRect.width;
}
}
19
Source : TrackballUIDrawer.cs
with MIT License
from JasonMa0012
with MIT License
from JasonMa0012
void DrawWheel(ref Vector4 value, bool overrideState)
{
var wheelRect = GUILayoutUtility.GetAspectRect(1f);
float size = wheelRect.width;
float hsize = size / 2f;
float radius = 0.38f * size;
Vector3 hsv;
Color.RGBToHSV(value, out hsv.x, out hsv.y, out hsv.z);
float offset = value.w;
// Thumb
var thumbPos = Vector2.zero;
float theta = hsv.x * (Mathf.PI * 2f);
thumbPos.x = Mathf.Cos(theta + (Mathf.PI / 2f));
thumbPos.y = Mathf.Sin(theta - (Mathf.PI / 2f));
thumbPos *= hsv.y * radius;
// Draw the wheel
if (Event.current.type == EventType.Repaint)
{
// Style init
if (s_WheelThumb == null)
{
s_WheelThumb = new GUIStyle("ColorPicker2DThumb");
s_WheelThumbSize = new Vector2(
!Mathf.Approximately(s_WheelThumb.fixedWidth, 0f) ? s_WheelThumb.fixedWidth : s_WheelThumb.padding.horizontal,
!Mathf.Approximately(s_WheelThumb.fixedHeight, 0f) ? s_WheelThumb.fixedHeight : s_WheelThumb.padding.vertical
);
}
// Retina support
float scale = EditorGUIUtility.pixelsPerPoint;
// Wheel texture
var oldRT = RenderTexture.active;
var rt = RenderTexture.GetTemporary((int)(size * scale), (int)(size * scale), 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
s_Material.SetFloat("_Offset", offset);
s_Material.SetFloat("_DisabledState", overrideState && GUI.enabled ? 1f : 0.5f);
s_Material.SetVector("_Resolution", new Vector2(size * scale, size * scale / 2f));
Graphics.Blit(null, rt, s_Material, EditorGUIUtility.isProSkin ? 0 : 1);
RenderTexture.active = oldRT;
GUI.DrawTexture(wheelRect, rt);
RenderTexture.ReleaseTemporary(rt);
var thumbSize = s_WheelThumbSize;
var thumbSizeH = thumbSize / 2f;
s_WheelThumb.Draw(new Rect(wheelRect.x + hsize + thumbPos.x - thumbSizeH.x, wheelRect.y + hsize + thumbPos.y - thumbSizeH.y, thumbSize.x, thumbSize.y), false, false, false, false);
}
// Input
var bounds = wheelRect;
bounds.x += hsize - radius;
bounds.y += hsize - radius;
bounds.width = bounds.height = radius * 2f;
hsv = GetInput(bounds, hsv, thumbPos, radius);
Vector3Int displayHSV = new Vector3Int(Mathf.RoundToInt(hsv.x * 360), Mathf.RoundToInt(hsv.y * 100), 100);
bool displayInputFields = EditorGUIUtility.currentViewWidth > 600;
if (displayInputFields)
{
var valuesRect = GUILayoutUtility.GetRect(1f, 17f);
valuesRect.width /= 5f;
float textOff = valuesRect.width * 0.2f;
EditorGUI.LabelField(valuesRect, "Y");
valuesRect.x += textOff;
offset = EditorGUI.DelayedFloatField(valuesRect, offset);
offset = Mathf.Clamp(offset, -1.0f, 1.0f);
valuesRect.x += valuesRect.width + valuesRect.width * 0.05f;
EditorGUI.LabelField(valuesRect, "H");
valuesRect.x += textOff;
displayHSV.x = EditorGUI.DelayedIntField(valuesRect, displayHSV.x);
hsv.x = displayHSV.x / 360.0f;
valuesRect.x += valuesRect.width + valuesRect.width * 0.05f;
EditorGUI.LabelField(valuesRect, "S");
valuesRect.x += textOff;
displayHSV.y = EditorGUI.DelayedIntField(valuesRect, displayHSV.y);
displayHSV.y = Mathf.Clamp(displayHSV.y, 0, 100);
hsv.y = displayHSV.y / 100.0f;
valuesRect.x += valuesRect.width + valuesRect.width * 0.05f;
EditorGUI.LabelField(valuesRect, "V");
valuesRect.x += textOff;
GUI.enabled = false;
EditorGUI.IntField(valuesRect, 100);
GUI.enabled = true;
}
value = Color.HSVToRGB(hsv.x, hsv.y, 1f);
value.w = offset;
// Offset
var sliderRect = GUILayoutUtility.GetRect(1f, 17f);
float padding = sliderRect.width * 0.05f; // 5% padding
sliderRect.xMin += padding;
sliderRect.xMax -= padding;
value.w = GUI.HorizontalSlider(sliderRect, value.w, -1f, 1f);
if (m_ComputeFunc == null)
return;
// Values
var displayValue = m_ComputeFunc(value);
using (new EditorGUI.DisabledGroupScope(true))
{
var valuesRect = GUILayoutUtility.GetRect(1f, 17f);
valuesRect.width /= (displayInputFields ? 4f : 3.0f);
if(displayInputFields)
{
GUI.Label(valuesRect, "RGB Value:", EditorStyles.centeredGreyMiniLabel);
valuesRect.x += valuesRect.width;
}
GUI.Label(valuesRect, displayValue.x.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
valuesRect.x += valuesRect.width;
GUI.Label(valuesRect, displayValue.y.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
valuesRect.x += valuesRect.width;
GUI.Label(valuesRect, displayValue.z.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
valuesRect.x += valuesRect.width;
}
}