public void Initialize()
 {
     if (hasInitialized)
     {
         return;
     }
     rowContainer   = transform.parent.gameObject.GetComponent <RowContainer>();
     hasInitialized = true;
 }
Example #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(padding);
            EditorGUILayout.PropertyField(spacing);
            EditorGUILayout.PropertyField(alignment);
            EditorGUILayout.PropertyField(bounds);
            EditorGUILayout.PropertyField(log);

            serializedObject.ApplyModifiedProperties();

            if (GUILayout.Button("Move Children"))
            {
                if (target.GetType() == typeof(RowContainer))
                {
                    RowContainer rowContainer = (RowContainer)target;
                    rowContainer.MoveChildren();
                }
            }
        }
        private void BroadcastContainerWidth()
        {
#if UNITY_EDITOR
            Undo.SetCurrentGroupName("ColumnContainer BroadcastContainerWidth");
            int group = Undo.GetCurrentGroup();
#endif

            for (int i = 0; i < transform.childCount; i++)
            {
                Transform    child        = transform.GetChild(i);
                RowContainer rowContainer = child.GetComponent <RowContainer>();
                if (rowContainer)
                {
#if UNITY_EDITOR
                    Undo.RecordObject(child.transform, "Child SetParentContainerWidth");
#endif
                    rowContainer.SetParentContainerWidth(bounds.size.x);
                }
            }
#if UNITY_EDITOR
            Undo.CollapseUndoOperations(group);
#endif
        }