protected override void NotifyPrimitiveChanged(SyncPrimitive primitive)
 {
     if (primitive is SyncString)
     {
         SyncStringChanged((SyncString)primitive);
     }
 }
 protected override void NotifyPrimitiveChanged(SyncPrimitive primitive)
 {
     if (primitive is SyncBool)
     {
         SyncBoolChanged((SyncBool)primitive);
     }
 }
Пример #3
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();
            }
        }
Пример #4
0
 protected override void OnFloatElementChanged(long elementID, float newValue)
 {
     if (GameObject.Find("AppConfig").GetComponent <AppConfig>().IsServerInstance)
     {
         base.OnFloatElementChanged(elementID, newValue);
     }
     else
     {
         if (_primitiveMap.ContainsKey(elementID))
         {
             SyncPrimitive primitive = _primitiveMap[elementID];
             primitive.UpdateFromRemote(newValue);
             NotifyPrimitiveChanged(primitive);
         }
         else
         {
             Debug.LogWarningFormat("Unknown primitive, discarding update.  Value: {1}, Id: {2}", elementID, newValue);
         }
     }
 }
 public void AddRemotePrimitive(long guid, SyncPrimitive syncPrimitve)
 {
     _primitveMap.Add(guid, syncPrimitve);
 }