Exemplo n.º 1
0
        private void DrawDataModelGUI(SyncPrimitive syncPrimitive, string parentPath)
        {
            string name  = syncPrimitive.FieldName;
            object value = syncPrimitive.RawValue;

            SyncObject SyncObject = syncPrimitive as SyncObject;

            if (SyncObject != null)
            {
                bool foldout = false;
                if (foldoutGUIMap.ContainsKey(SyncObject))
                {
                    foldout = foldoutGUIMap[SyncObject];
                }

                int    ownerId    = SyncObject.OwnerId;
                string owner      = ownerId == int.MaxValue ? string.Empty : ownerId.ToString();
                string objectType = SyncObject.ObjectType;

                foldout = EditorGUILayout.Foldout(foldout, string.Format("{0} (Owner:{1} Type:{2})", name, owner, objectType));
                foldoutGUIMap[SyncObject] = foldout;

                if (foldout)
                {
                    EditorGUI.indentLevel++;

                    SyncPrimitive[] children = SyncObject.GetChildren();
                    for (int i = 0; i < children.Length; i++)
                    {
                        DrawDataModelGUI(children[i], parentPath + "/" + name);
                    }

                    EditorGUI.indentLevel--;
                }
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(name, GUILayout.MaxWidth(125));
                EditorGUILayout.LabelField(value != null ? value.ToString() : "null", GUILayout.MaxWidth(200));
                EditorGUILayout.LabelField(syncPrimitive.NetworkElement != null ? "live" : "local",
                                           GUILayout.MaxWidth(50));
                if (syncPrimitive.NetworkElement != null)
                {
                    EditorGUILayout.LabelField(parentPath + "/" + name, GUILayout.MaxWidth(500));
                }

                EditorGUILayout.EndHorizontal();
            }
        }