示例#1
0
    void ShowRebuildLablesButton()
    {
        if (GUILayout.Button("Rebuild lables in selection"))
        {
            Object[] selGOs = Selection.GetFiltered(typeof(GameObject), SelectionMode.Deep);
            Debug.Log("GO found: " + selGOs.Length);

            int labelsInSelection = 0;
            foreach (GameObject go in selGOs)
            {
                GUIBase_Label label = go.GetComponent <GUIBase_Label>();
                if (label == null)
                {
                    continue;
                }

                labelsInSelection++;

                Debug.Log("Rebuilding label " + label.name + ": " + label.Text);

                label.GenerateRunTimeData();
                EditorUtility.SetDirty(label);
            }

            if (labelsInSelection > 0)
            {
                Debug.Log("Rebuild " + labelsInSelection + " labels.");
            }
            else
            {
                Debug.LogWarning("No GUIBase_Label in selection.");
            }
        }
    }
    void Update()
    {
        if (Application.isPlaying == true)
        {
            return;
        }

        GUIBase_Label label = m_Label;

        if (label == null)
        {
            label = GetComponent <GUIBase_Label>();
        }
        if (label == null)
        {
            return;
        }

        bool sizeChanged = false;

        if (m_Width != m_OldWidth || m_Height != m_OldHeight)
        {
            sizeChanged = true;
            m_OldWidth  = m_Width;
            m_OldHeight = m_Height;
        }

        if (sizeChanged == false)
        {
            return;
        }

        Transform trans      = transform;
        Vector3   position   = trans.position;
        Vector3   lossyScale = trans.lossyScale;

        RegenerateBoundaries(label, position, lossyScale);

        label.GenerateRunTimeData();
    }