Make work with astra

This commit is contained in:
Andras Schmelczer 2026-09-14 08:01:49 +01:00
commit c8ee5045e2
5 changed files with 6338 additions and 4613 deletions

View file

@ -1,40 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using System;
using System.Collections;
using UnityEngine;
/* Itt lehet állítani, hogy melyik build legyen szerver és melyik kliens.
* WebGL szerver nem lehet.
*/
public class canvasChooser : MonoBehaviour
{
public GameObject serverStartCanvas;
public GameObject clientStartCanvas;
public GameObject mainCamera;
public class canvasChooser : MonoBehaviour {
private IEnumerator Start()
{
string[] args = Environment.GetCommandLineArgs();
bool server = Array.IndexOf(args, "--server") >= 0;
serverStartCanvas.SetActive(server);
clientStartCanvas.SetActive(!server);
mainCamera.SetActive(!server);
public GameObject serverStartCanvas;
public GameObject clientStartCanvas;
public GameObject mainCamera;
// Use this for initialization
void Start () {
#if UNITY_STANDALONE
serverStartCanvas.SetActive(false);
clientStartCanvas.SetActive(true);
mainCamera.SetActive(true);
/*serverStartCanvas.SetActive(true);
clientStartCanvas.SetActive(false);
mainCamera.SetActive(false);*/
#endif
#if UNITY_WEBGL
serverStartCanvas.SetActive(false);
clientStartCanvas.SetActive(true);
mainCamera.SetActive(true);
#endif
#if UNITY_EDITOR
serverStartCanvas.SetActive(false);
clientStartCanvas.SetActive(true);
mainCamera.SetActive(true);
#endif
}
// Let the scene finish starting before UNet activates its scene objects.
yield return null;
if (server)
{
serverStartMenu menu = serverStartCanvas.GetComponent<serverStartMenu>();
string trafficUrl = Argument(args, "--traffic-url");
string eventUrl = Argument(args, "--event-url");
if (trafficUrl != null) menu.trafficAddress.text = trafficUrl.TrimEnd('/');
if (eventUrl != null) menu.eventAddress.text = eventUrl.TrimEnd('/');
menu.createServer();
Debug.Log("Simulation server started on port " + menu.network.networkPort);
}
else
{
string address = Argument(args, "--connect");
if (address != null)
clientStartCanvas.GetComponent<clientMenu>().joinServer(address);
}
}
private static string Argument(string[] args, string name)
{
int index = Array.IndexOf(args, name);
return index >= 0 && index + 1 < args.Length ? args[index + 1] : null;
}
}

View file

@ -1,40 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/* Itt lehet állítani, hogy melyik build legyen szerver és melyik kliens.
* WebGL szerver nem lehet.
*/
public class canvasChooser : MonoBehaviour {
public GameObject serverStartCanvas;
public GameObject clientStartCanvas;
public GameObject mainCamera;
// Use this for initialization
void Start () {
#if UNITY_STANDALONE
serverStartCanvas.SetActive(false);
clientStartCanvas.SetActive(true);
mainCamera.SetActive(true);
/*serverStartCanvas.SetActive(true);
clientStartCanvas.SetActive(false);
mainCamera.SetActive(false);*/
#endif
#if UNITY_WEBGL
serverStartCanvas.SetActive(false);
clientStartCanvas.SetActive(true);
mainCamera.SetActive(true);
#endif
#if UNITY_EDITOR
serverStartCanvas.SetActive(false);
clientStartCanvas.SetActive(true);
mainCamera.SetActive(true);
#endif
}
}
fileFormatVersion: 2
guid: a5533452e90b11345b3c3510cc82a51f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -30,6 +30,8 @@ public class clientGameMenu : NetworkBehaviour {
[ClientRpc(channel = 0)]
public void RpcSetNewTweet (Tweet newTweet)
{
if (tweetAnimator == null)
tweetAnimator = new TweetAnimator(0.5f, 7.5f, tweetContainer);
tweetAnimator.SetNewTweet(newTweet);
}

View file

@ -34,8 +34,6 @@ public class serverRunningMenu : NetworkBehaviour
if (timePassed < 1) timePassed += Time.deltaTime;
else
{
Debug.Log(NetworkServer.connections);
Debug.Log(NetworkServer.connections.Count);
timePassed = 0;

View file

@ -1,33 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
[NetworkSettings(channel = 0, sendInterval = 0)]
public class serverStartMenu : NetworkBehaviour
{
public TrafficController traffic;
public tweetPoller tweet;
public InputField trafficAddress;
public InputField eventAddress;
public GameObject next;
public NetworkManager network;
public void createServer ()
{
if(trafficAddress.text != "")
traffic.url = trafficAddress.text;
if (eventAddress.text != "")
tweet.url = eventAddress.text;
network.StartServer();
gameObject.SetActive(false);
next.SetActive(true);
}
}
fileFormatVersion: 2
guid: 02335c5d9c8e07347918bd15ceb1adc2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: