Exemple #1
0
    protected void AddButtonGUI(Func <TItem> createBlankFunction)
    {
        if (GUILayout.Button("Add"))
        {
            for (int i = 0; i < m_ItemsProp.arraySize; i++)
            {
                SerializedProperty elementProp = m_ItemsProp.GetArrayElementAtIndex(i);
                elementProp.isExpanded = false;
            }

            TItem newElement = createBlankFunction();
            m_ItemsProp.AddObjectToArrayAsSubAsset(m_Asset, true, newElement);
            m_ItemsProp.GetArrayElementAtIndex(m_ItemsProp.arraySize - 1).isExpanded = true;
        }
    }
Exemple #2
0
 public void AddElementButtonGUI(SerializedProperty arrayProp, Object collectionAsset)
 {
     if (GUILayout.Button("Add"))
     {
         arrayProp.AddObjectToArrayAsSubAsset <TElement> (collectionAsset, true);
     }
 }