protected static void AddWidgetToBinder(UINode node) { var so = new SerializedObject(node); var objectsBinds = so.FindProperty("m_Binder").FindPropertyRelative("m_ObjectBinds"); foreach (var widget in node.GetComponentsInChildren <UIWidget>(true)) { var view = widget.GetComponentInParentHard <UIView>(); if ((view == node) || (node is UIMaster) && view == null) { var alreadyAdded = false; for (var i = 0; i < objectsBinds.arraySize; ++i) { if (objectsBinds.GetArrayElementAtIndex(i).objectReferenceValue == widget) { alreadyAdded = true; break; } } if (alreadyAdded == false) { objectsBinds.arraySize++; objectsBinds.GetArrayElementAtIndex(objectsBinds.arraySize - 1).objectReferenceValue = widget; } } } so.ApplyModifiedProperties(); }
protected static void AddViewToBinder(UINode node) { var so = new SerializedObject(node); var objectsBinds = so.FindProperty("m_Binder").FindPropertyRelative("m_ObjectBinds"); foreach (var view in node.GetComponentsInChildren <UIView>(true)) { var alreadyAdded = false; for (var i = 0; i < objectsBinds.arraySize; ++i) { if (objectsBinds.GetArrayElementAtIndex(i).objectReferenceValue == view.transform.parent) { alreadyAdded = true; break; } } if (alreadyAdded == false) { objectsBinds.arraySize++; objectsBinds.GetArrayElementAtIndex(objectsBinds.arraySize - 1).objectReferenceValue = view.transform.parent; } if (view.LoadMode == UIViewLoadMode.Always) { alreadyAdded = false; for (var i = 0; i < objectsBinds.arraySize; ++i) { if (objectsBinds.GetArrayElementAtIndex(i).objectReferenceValue == view.transform) { alreadyAdded = true; break; } } if (alreadyAdded == false) { objectsBinds.arraySize++; objectsBinds.GetArrayElementAtIndex(objectsBinds.arraySize - 1).objectReferenceValue = view.transform; } } } so.ApplyModifiedProperties(); }