Skip to content

Instantly share code, notes, and snippets.

@AndrewWeston9
Last active October 6, 2017 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewWeston9/ca792e5564a09c9258fdf1a0a96d00fd to your computer and use it in GitHub Desktop.
Save AndrewWeston9/ca792e5564a09c9258fdf1a0a96d00fd to your computer and use it in GitHub Desktop.
EmoteWheel.cs Snippet: Created by another team member, I took their code and changed it to work in a network environment, sending the emotes between clients through the server.
public void ButtonAction()
{
buttons[CurMenuItem].sceneimage.color = buttons[CurMenuItem].PressedColor;
GameObject Player = this.transform.parent.gameObject;
NetworkInstanceId netID = Player.GetComponent<NetworkIdentity>().netId;
Debug.Log ("Sending emote with networkID: " + netID.ToString());
Vector3 offset = new Vector3(0.0f, 2.5f, 0.0f);
//IconObject DisplayEmote;
if (CurMenuItem == 0)
{
SendEmoteMessageAndClientID m = new SendEmoteMessageAndClientID();
m.emoteType = 0;
m.netId = netID;
NetworkManager.singleton.client.Send (LevelMsgType.EmoteSingleSender, m);
}
else if (CurMenuItem == 1)
{
SendEmoteMessageAndClientID m = new SendEmoteMessageAndClientID();
m.emoteType = 1;
m.netId = netID;
NetworkManager.singleton.client.Send (LevelMsgType.EmoteSingleSender, m);
}
else if (CurMenuItem == 2)
{
SendEmoteMessageAndClientID m = new SendEmoteMessageAndClientID();
m.emoteType = 2;
m.netId = netID;
NetworkManager.singleton.client.Send (LevelMsgType.EmoteSingleSender, m);
}
else if (CurMenuItem == 3)
{
SendEmoteMessageAndClientID m = new SendEmoteMessageAndClientID();
m.emoteType = 3;
m.netId = netID;
NetworkManager.singleton.client.Send (LevelMsgType.EmoteSingleSender, m);
}
menuon = false;
}
}
public class IconObject : MonoBehaviour
{
public void GetSprite(Sprite z)
{
//Emotetype = z;
}
public GameObject EmotePicture;
GameObject Player;
Vector3 offset = new Vector3(0.0f, 2.5f, 0.0f);
// public Sprite Emotetype;
// SpriteRenderer SR;
NetworkInstanceId NetID;
public float lifetime = 2.0f;
public void PlayerNetID (NetworkInstanceId netId)
{
NetID = netId;
Player = ClientScene.FindLocalObject(NetID);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment