Beispiel #1
0
    private void Awake()
    {
        ServerButton.onClick.AddListener(() =>
        {
            // try to start the server
            VoxelData voxelData = null;
            try {
                voxelData = VoxelSerializer.VoxelDataFromFile(LoadPath);
            } catch (Exception) {
                voxelData = null;
            }
            if (voxelData == null)
            {
                voxelData = new VoxelData();
            }
            try {
                Server.Start(Port, Port, Config.SERVER_LOG_FILE, voxelData);
            } catch (Exception e) {
                WriteToErrorBox(e.ToString());
            }

            // this thread does nothing now...
        });

        ClientButton.onClick.AddListener(() =>
        {
            // try to start the client
            try {
                Client.Start(IpAddress, Port, Port, Config.CLIENT_LOG_FILE);
            } catch (Exception e) {
                WriteToErrorBox(e.ToString());
                return;
            }

            // load editor if client successfully starts
            Application.LoadLevel(1);
        });

        ExitButton.onClick.AddListener(Application.Quit);
    }
Beispiel #2
0
 /// <summary>
 /// Only load from file before the scene is live (before the user can edit the model)
 /// </summary>
 public void LoadFromFile(string filepath)
 {
     _voxelData = VoxelSerializer.VoxelDataFromFile(filepath);
     _voxelRenderer.RenderMesh(_voxelData);
 }