Fix text prop caching and an exception in Server.cs
This commit is contained in:
parent
d634e862ea
commit
9f307d7632
@ -139,7 +139,7 @@ namespace Cyber.Networking.Serverside {
|
|||||||
SendToAll(PktType.TextMessage, new TextMessagePkt("Server: " + args[0]));
|
SendToAll(PktType.TextMessage, new TextMessagePkt("Server: " + args[0]));
|
||||||
});
|
});
|
||||||
|
|
||||||
gameObject.AddComponent<Syncer>();
|
Syncer = gameObject.AddComponent<Syncer>();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,20 @@ namespace Cyber.Util {
|
|||||||
/// <param name="forceRender">Whether the texture should be rendered
|
/// <param name="forceRender">Whether the texture should be rendered
|
||||||
/// again even if it's cached.</param>
|
/// again even if it's cached.</param>
|
||||||
public static Texture2D GetText(TextTextureProperties text, bool forceRender = false) {
|
public static Texture2D GetText(TextTextureProperties text, bool forceRender = false) {
|
||||||
if (forceRender || !Cache.ContainsKey(text.Text)) {
|
string Hash = CreateHash(text);
|
||||||
Cache[text.Text] = Singleton.RenderText(text);
|
if (forceRender || !Cache.ContainsKey(Hash)) {
|
||||||
|
Cache[Hash] = Singleton.RenderText(text);
|
||||||
|
Term.Println("Created a new texture for:");
|
||||||
|
Term.Println(Hash);
|
||||||
|
Term.Println("====");
|
||||||
}
|
}
|
||||||
return Cache[text.Text];
|
return Cache[Hash];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string CreateHash(TextTextureProperties text) {
|
||||||
|
return text.Text + "," + text.Width + "," + text.Height + "," +
|
||||||
|
text.FontSize + "," + text.Background.r + "," +
|
||||||
|
text.Background.g + "," + text.Background.b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user