-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added different color options to the character shader * Refactored the character shader, exposed player colors to the material inspector * More refactoring/cleaning of player color shader * Edited player materials to work with shader refactor * Another refactor of the color shader * Added color switching script * Added the color changing script to the networked character's mesh * Update Basic/ClientDriven/Assets/Scripts/ClientPlayerColor.cs Co-authored-by: Sam Bellomo <[email protected]> Co-authored-by: Sam Bellomo <[email protected]>
- Loading branch information
1 parent
ec1eddd
commit 2dbe6ef
Showing
16 changed files
with
9,853 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Unity.Netcode; | ||
using UnityEngine; | ||
|
||
/// <summary> | ||
/// A script to set the color of each player based on OwnerClientId | ||
/// </summary> | ||
|
||
public class ClientPlayerColor : NetworkBehaviour | ||
{ | ||
public override void OnNetworkSpawn() | ||
{ | ||
base.OnNetworkSpawn(); | ||
SkinnedMeshRenderer m_Renderer = GetComponent<SkinnedMeshRenderer>(); | ||
|
||
foreach (var material in m_Renderer.materials) | ||
{ | ||
// OwnerClientId is used here for debugging purposes. A live game should use a session manager to make sure reconnecting players still get the same color, as client IDs could be reused for other clients between disconnect and reconnect. See Boss Room for a session manager example. | ||
material.SetFloat("_Color_Index", OwnerClientId); | ||
} | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Basic/ClientDriven/Assets/Scripts/ClientPlayerColor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.