Пример #1
0
 /// <summary>
 /// Set the specified matrix and styles.
 /// </summary>
 /// <param name="matrix">Matrix.</param>
 /// <param name="styles">styles.</param>
 public void Set(Matrix4x4 matrix = default(Matrix4x4), LW_Styles styles = null)
 {
     if (matrix == Matrix4x4.zero)
     {
         matrix = Matrix4x4.identity;
     }
     this.transform = matrix;
     this.styles    = styles;
 }
Пример #2
0
 protected override void OnDestroy()
 {
                 #if UNITY_EDITOR
     if (m_Styles != null)
     {
         m_Styles = LW_Utilities.SafeDestroy <LW_Styles>(m_Styles);
     }
                 #endif
     base.OnDestroy();
 }
Пример #3
0
        protected override void OnEnable()
        {
            if (string.IsNullOrEmpty(name))
            {
                name = "Graphic";
            }
            if (m_Styles == null)
            {
                m_Styles = CreateInstance <LW_Styles>();
                                #if UNITY_EDITOR
                m_Styles.SetHideFlags(hideFlags);
                                #endif
            }

            base.OnEnable();
        }
Пример #4
0
 public override void SetElementDirty()
 {
     if (m_ScaleWithStroke && m_Stroke == null && m_OnElementDirtyCallback != null)
     {
         LW_Styles styles = m_OnElementDirtyCallback.Target as LW_Styles;
         if (styles != null)
         {
             for (int i = 0; i < styles.Count; i++)
             {
                 if (styles[i] is LW_Stroke)
                 {
                     m_Stroke = styles[i] as LW_Stroke;
                 }
             }
         }
     }
     base.SetElementDirty();
 }
Пример #5
0
        internal override void CopyPropertiesFrom(LW_Element element)
        {
            if (element is LW_Styles)
            {
                LW_Styles styles = element as LW_Styles;

                bool stylesMatch = m_StylesList != null && styles.m_StylesList != null && m_StylesList.Count == styles.m_StylesList.Count;
                if (stylesMatch)
                {
                    for (int i = 0; i < m_StylesList.Count; i++)
                    {
                        if (m_StylesList[i].GetType() != styles.m_StylesList[i].GetType() || m_StylesList[i] == styles.m_StylesList[i])
                        {
                            stylesMatch = false;
                            break;
                        }
                    }
                }
                if (stylesMatch)
                {
                    for (int i = 0; i < m_StylesList.Count; i++)
                    {
                        m_StylesList[i].CopyPropertiesFrom(styles.m_StylesList[i]);
                    }
                }
                else
                {
                    if (m_StylesList != null)
                    {
                        for (int i = 0; i < m_StylesList.Count; i++)
                        {
                            if (m_StylesList[i] != null)
                            {
                                LW_Utilities.SafeDestroy(m_StylesList[i]);
                            }
                        }
                        m_StylesList.Clear();
                    }
                    if (styles.m_StylesList != null)
                    {
                        if (m_StylesList == null)
                        {
                            m_StylesList = new List <LW_Style>(styles.m_StylesList.Count);
                        }
                        else if (m_StylesList.Capacity < styles.m_StylesList.Count)
                        {
                            m_StylesList.Capacity = styles.m_StylesList.Count;
                        }

                        for (int i = 0; i < styles.m_StylesList.Count; i++)
                        {
                            if (styles.m_StylesList[i] != null)
                            {
                                LW_Style copiedElement = styles.m_StylesList[i].Copy() as LW_Style;
                                m_StylesList.Add(copiedElement);
                            }
                        }
                    }
                }
            }
            base.CopyPropertiesFrom(element);
        }