public override void OnServerAddPlayer(NetworkConnection conn)
        {
            // add player at correct spawn position
            //Transform start = numPlayers == 0 ? leftRacketSpawn : rightRacketSpawn;
            Debug.Log("Server adding player...");
            if (numPlayers == 0)
            {
                foreach (GameObject obj in spawnPrefabs)
                {
                    if (obj.tag == "Player")
                    {
                        player = Instantiate(obj);
                        NetworkServer.Spawn(player, conn);
                        NetworkServer.AddPlayerForConnection(conn, player);
                    }
                }
                foreach (GameObject obj in spawnPrefabs)
                {
                    if (obj.tag == "GoalKeeperPlayer")
                    {
                        player = Instantiate(obj);
                        NetworkServer.Spawn(player, conn);
                        NetworkServer.AddPlayerForConnection(conn, player);
                    }
                }
            }
            else if (numPlayers == 1)
            {
                foreach (GameObject obj in spawnPrefabs)
                {
                    if (obj.tag == "Enemy")
                    {
                        player = Instantiate(obj);
                        NetworkServer.Spawn(player, conn);
                        NetworkServer.AddPlayerForConnection(conn, player);
                    }
                }
                foreach (GameObject obj in spawnPrefabs)
                {
                    if (obj.tag == "GoalKeeperEnemy")
                    {
                        player = Instantiate(obj);
                        NetworkServer.Spawn(player, conn);
                        NetworkServer.AddPlayerForConnection(conn, player);
                    }
                }
            }

            //if(numPlayers == 0)
            //{
            //    player = Instantiate(playerPrefab, start.position, start.rotation);
            //    NetworkServer.AddPlayerForConnection(conn, player);


            //}
            //else if(numPlayers == 1)
            //{
            //    player = Instantiate(EnemyPrefab, start.position, start.rotation);
            //    NetworkServer.AddPlayerForConnection(conn, player);
            //}

            // spawn ball if reach maximum players
            //1 == 1 player , 2 == 2 players
            if (numPlayers == 1)
            {
                ball = Instantiate(spawnPrefabs.Find(prefab => prefab.tag == "Ball"));
                NetworkServer.Spawn(ball);
            }
        }
        public override void OnInspectorGUI()
        {
            if (serverOnlyProperty == null)
            {
                initialized = false;
            }

            Init();

            serializedObject.Update();

            if (serverOnlyProperty.boolValue)
            {
                EditorGUILayout.PropertyField(serverOnlyProperty, serverOnlyLabel);
                EditorGUILayout.LabelField("Local Player Authority cannot be set for server-only objects");
            }
            else if (localPlayerAuthorityProperty.boolValue)
            {
                EditorGUILayout.LabelField("Server Only cannot be set for Local Player Authority objects");
                EditorGUILayout.PropertyField(localPlayerAuthorityProperty, localPlayerAuthorityLabel);
            }
            else
            {
                EditorGUILayout.PropertyField(serverOnlyProperty, serverOnlyLabel);
                EditorGUILayout.PropertyField(localPlayerAuthorityProperty, localPlayerAuthorityLabel);
            }

            serializedObject.ApplyModifiedProperties();

            if (!Application.isPlaying)
            {
                return;
            }

            // Runtime actions below here

            EditorGUILayout.Separator();

            if (networkIdentity.observers != null && networkIdentity.observers.Count > 0)
            {
                showObservers = EditorGUILayout.Foldout(showObservers, "Observers");
                if (showObservers)
                {
                    EditorGUI.indentLevel += 1;
                    foreach (KeyValuePair <int, NetworkConnection> kvp in networkIdentity.observers)
                    {
                        if (kvp.Value.playerController != null)
                        {
                            EditorGUILayout.ObjectField("Connection " + kvp.Value.connectionId, kvp.Value.playerController.gameObject, typeof(GameObject), false);
                        }
                        else
                        {
                            EditorGUILayout.TextField("Connection " + kvp.Value.connectionId);
                        }
                    }
                    EditorGUI.indentLevel -= 1;
                }
            }

            if (PrefabUtility.IsPartOfPrefabAsset(networkIdentity.gameObject))
            {
                return;
            }

            if (networkIdentity.gameObject.activeSelf && networkIdentity.netId == 0 && NetworkServer.active)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(spawnLabel);
                if (GUILayout.Toggle(false, "Spawn", EditorStyles.miniButtonLeft))
                {
                    NetworkServer.Spawn(networkIdentity.gameObject);
                    EditorUtility.SetDirty(target);  // preview window STILL doens't update immediately..
                }
                EditorGUILayout.EndHorizontal();
            }
        }