internal override void CopyPropertiesFrom(LW_Element element) { LW_Marker marker = element as LW_Marker; if (marker != null) { m_Graphic = marker.m_Graphic; m_Position = marker.m_Position; m_EulerRotation = marker.m_EulerRotation; m_Scale = marker.m_Scale; m_ScaleWithStroke = marker.m_ScaleWithStroke; m_Stroke = marker.m_Stroke; m_VariableScales = marker.m_VariableScales; m_AtStart = marker.m_AtStart; m_AtMiddle = marker.m_AtMiddle; m_AtEnd = marker.m_AtEnd; m_FlipEnd = marker.m_FlipEnd; m_FaceForward = marker.m_FaceForward; m_PlacementMode = marker.m_PlacementMode; m_FixedSpacingLength = marker.m_FixedSpacingLength; m_FixedJustification = marker.m_FixedJustification; m_NumberOfMarkers = marker.m_NumberOfMarkers; } base.CopyPropertiesFrom(element); }
public static LW_Marker Create(LW_Graphic graphic = null, bool atStart = false, bool atMiddle = false, bool atEnd = false, PlacementMode placement = PlacementMode.SpaceEvenly, int numberOfMarkers = 3) { LW_Marker instance = CreateInstance <LW_Marker>(); instance.Set(graphic, atStart, atMiddle, atEnd, placement, numberOfMarkers); return(instance); }
/// <summary> /// Set all properties of the marker in one call. /// </summary> /// <param name="marker"></param> /// <param name="atStart"></param> /// <param name="atMiddle"></param> /// <param name="atEnd"></param> /// <param name="faceForward"></param> /// <param name="angle"></param> /// <param name="spaceEvenly"></param> /// <param name="numberOfMarker"></param> public void Set(LW_Graphic graphic = null, bool atStart = false, bool atMiddle = false, bool atEnd = false, PlacementMode placement = PlacementMode.SpaceEvenly, int numberOfMarkers = 3) { this.graphic = graphic; this.atStart = atStart; this.atMiddle = atMiddle; this.atEnd = atEnd; this.placementMode = placement; SetElementDirty(); }
public static T Get(LW_Graphic graphic, LW_Style style) { int key = GetCacheKey(graphic.id, style.id); T buffer = Get(key); buffer.graphic = graphic; buffer.style = style; return(buffer); }
/// <summary> /// Inserts a new element at the provided index. If an element already exists at the index. the new element is a copy of the old element. /// </summary> /// <param name="index"></param> public void InsertAt(int index) { if (m_GraphicsList != null && index > -1 && index < m_GraphicsList.Count) { LW_Graphic copiedElement = m_GraphicsList[index].Copy() as LW_Graphic; m_GraphicsList.Insert(index, copiedElement); m_GraphicsList[index].RegisterCallbacks(OnChildSetElementDirty); SetElementDirty(); } }
/// <summary> /// Moves an element from the srcIndex to the dstIndex /// </summary> /// <param name="srcIndex"></param> /// <param name="dstIndex"></param> public void Move(int srcIndex, int dstIndex) { if (m_GraphicsList != null && dstIndex > -1 && dstIndex < m_GraphicsList.Count) { LW_Graphic item = m_GraphicsList[srcIndex]; m_GraphicsList.RemoveAt(srcIndex); m_GraphicsList.Insert(dstIndex, item); SetElementDirty(); } }
public static T Get(LW_Graphic graphic, LW_Style style, LW_Canvas canvas) { int key = GetCacheKey(graphic.id, style.id, canvas.id); T buffer = Get(key); buffer.graphic = graphic; buffer.style = style; buffer.canvas = canvas; return(buffer); }
public void Set(LW_Graphic graphic = null, bool atStart = false, bool atMiddle = false, bool atEnd = false, float fixedSpacingLength = 5f, Justification fixedJustification = Justification.center) { this.graphic = graphic; this.atStart = atStart; this.atMiddle = atMiddle; this.atEnd = atEnd; this.placementMode = PlacementMode.AtFixedLengths; this.fixedSpacingLength = fixedSpacingLength; this.fixedJustification = fixedJustification; SetElementDirty(); }
/// <summary> /// Adds an element to the collection /// </summary> /// <param name="element"></param> public void Add(LW_Graphic item) { if (m_GraphicsList == null) { m_GraphicsList = new List <LW_Graphic>(); } if (!m_GraphicsList.Contains(item)) { m_GraphicsList.Add(item); item.RegisterCallbacks(OnChildSetElementDirty); SetElementDirty(); } }
/// <summary> /// Removes the provided element from the collection. /// </summary> /// <param name="element"></param> public bool Remove(LW_Graphic item) { if (m_GraphicsList != null && m_GraphicsList.Contains(item)) { item.UnregisterCallbacks(OnChildSetElementDirty); bool result = m_GraphicsList.Remove(item); LW_Utilities.SafeDestroy <LW_Graphic>(item); SetElementDirty(); return(result); } else { return(false); } }
internal override void CopyPropertiesFrom(LW_Element element) { if (element is LW_Graphic) { LW_Graphic graphic = element as LW_Graphic; m_Position = graphic.m_Position; m_EulerRotation = graphic.m_EulerRotation; m_Scale = graphic.m_Scale; if (m_Styles != null) { m_Styles.CopyPropertiesFrom(graphic.m_Styles); } RebuildShape(); } base.CopyPropertiesFrom(element); }
internal override void Reset() { base.Reset(); m_Graphic = null; m_Position = Vector3.zero; m_EulerRotation = Vector3.zero; m_Scale = Vector3.one; m_AtStart = false; m_AtMiddle = false; m_AtEnd = false; m_FlipEnd = false; m_FaceForward = false; m_PlacementMode = PlacementMode.SpaceEvenly; m_FixedSpacingLength = 5f; m_FixedJustification = Justification.center; m_NumberOfMarkers = 3; }
private static void RemoveGraphicFromDict(LW_Graphic graphic) { foreach (KeyValuePair <Material, LW_MaterialBuffer> kvp in s_MaterialDict) { LW_MaterialBuffer materialBuffer = kvp.Value; for (int i = 0; i < materialBuffer.vertexBuffers.Count; i++) { LW_VertexBuffer buffer = materialBuffer.vertexBuffers[i]; if (buffer.graphic == graphic) { if (!materialBuffer.emptyIndices.Contains(i)) { materialBuffer.emptyIndices.Push(i); } } } } }
internal override void CopyPropertiesFrom(LW_Element element) { if (element is LW_Group) { LW_Group group = element as LW_Group; bool groupMatches = m_GraphicsList != null && group.m_GraphicsList != null && m_GraphicsList.Count == group.m_GraphicsList.Count; if (groupMatches) { for (int i = 0; i < m_GraphicsList.Count; i++) { if (m_GraphicsList[i].GetType() != group.m_GraphicsList[i].GetType() || m_GraphicsList[i] == group.m_GraphicsList[i]) { groupMatches = false; break; } } } if (groupMatches) { for (int i = 0; i < m_GraphicsList.Count; i++) { m_GraphicsList[i].CopyPropertiesFrom(group.m_GraphicsList[i]); } } else { if (m_GraphicsList != null) { for (int i = 0; i < m_GraphicsList.Count; i++) { if (m_GraphicsList[i] != null) { LW_Utilities.SafeDestroy(m_GraphicsList[i]); } } m_GraphicsList = null; } if (group.m_GraphicsList != null) { if (m_GraphicsList == null) { m_GraphicsList = new List <LW_Graphic>(group.m_GraphicsList.Count); } else if (m_GraphicsList.Capacity < group.m_GraphicsList.Count) { m_GraphicsList.Capacity = group.m_GraphicsList.Count; } for (int i = 0; i < group.m_GraphicsList.Count; i++) { if (group.m_GraphicsList[i] != null) { LW_Graphic copiedElement = group.m_GraphicsList[i].Copy() as LW_Graphic; m_GraphicsList.Add(copiedElement); } } } } } base.CopyPropertiesFrom(element); }