public void GenerateTickHeadContent(MeshGenerationContext context) { const float tipY = 20f; const float height = 6f; const float width = 11f; const float middle = 6f; Color color; if (EditorGUIUtility.isProSkin) { color = m_DebugPlayhead ? ColorUtility.FromHtmlString("#234A6C") : Color.white; } else { color = m_DebugPlayhead ? ColorUtility.FromHtmlString("#2E5B8D") : Color.white; } MeshWriteData mesh = context.Allocate(3, 3); Vertex[] vertices = new Vertex[3]; vertices[0].position = new Vector3(middle, tipY, Vertex.nearZ); vertices[1].position = new Vector3(width, tipY - height, Vertex.nearZ); vertices[2].position = new Vector3(0, tipY - height, Vertex.nearZ); vertices[0].tint = color; vertices[1].tint = color; vertices[2].tint = color; mesh.SetAllVertices(vertices); mesh.SetAllIndices(new ushort[] { 0, 2, 1 }); }
public TagElement(Track track, TaggedAnimationClip clip, TagAnnotation tag) : base(track) { m_Tag = tag; focusable = true; AddToClassList("clipTagRoot"); m_ManipulateStartLabel = new Label(); m_ManipulateStartLabel.AddToClassList("tagManipulateStartLabel"); m_ManipulateStartLabel.AddToClassList("tagManipulateLabel"); m_ManipulateEndLabel = new Label(); m_ManipulateEndLabel.AddToClassList("tagManipulateEndLabel"); m_ManipulateEndLabel.AddToClassList("tagManipulateLabel"); m_BackgroundColor = AnnotationAttribute.GetColor(m_Tag.Type); var background = m_BackgroundColor; background.r *= k_BackgroundAlpha; background.g *= k_BackgroundAlpha; background.b *= k_BackgroundAlpha; style.backgroundColor = background; int hash = new Random(m_Tag.payload.GetHashedData()).Next(); Color colorFromValueHash = ColorUtility.FromHtmlString("#" + Convert.ToString(hash, 16)); Color borderColor = background; borderColor.r = (borderColor.r + colorFromValueHash.r) / 2; borderColor.g = (borderColor.g + colorFromValueHash.g) / 2; borderColor.b = (borderColor.b + colorFromValueHash.b) / 2; style.borderLeftColor = borderColor; style.borderBottomColor = borderColor; style.borderRightColor = borderColor; VisualElement startHandle = CreateHandle(TagManipulator.Mode.StartTime); startHandle.style.left = -4; Insert(0, startHandle); startHandle.Add(m_ManipulateStartLabel); m_LabelContainer.AddManipulator(new TagManipulator(this, TagManipulator.Mode.Body)); m_Label.text = string.IsNullOrEmpty(m_Tag.name) ? m_Tag.Name : m_Tag.name; VisualElement endHandle = CreateHandle(TagManipulator.Mode.Duration); endHandle.style.left = 4; Add(endHandle); endHandle.Add(m_ManipulateEndLabel); var contextMenuManipulator = new ContextualMenuManipulator(OpenTagRemoveMenu); this.AddManipulator(contextMenuManipulator); RegisterCallback <AttachToPanelEvent>(OnAttachToPanel); }
/// <summary> /// Constructs a new data attribute with the name and flags passed as argument. /// </summary> /// <param name="displayName">Display name to be used for the data type.</param> /// <param name="color">Color to be used for display purposes of this data type.</param> /// <param name="flag">Flags that control the behavior of this data type.</param> public DataAttribute(string displayName, string color, DataFlags flags = DataFlags.None) { this.color = ColorUtility.FromHtmlString(color); this.displayName = displayName; this.flags = flags; }
protected AnnotationAttribute(string displayName, string color) { m_Color = ColorUtility.FromHtmlString(color); m_DisplayName = displayName; }