Greetings!
I am new to unity and smartfox ,
though ive managed to set up a networking chat with the help of tutorials and the islanddemo.., I can't get the smartfox usernames hovering above my players
I understand they have to be dynamically generated in a GUIText?
And I see they are already there in the bubblepopup script? I simply am not experienced enough to understand how to get them from there (
Can someone plse help this noob out ..., lol a short piece of code would be appreciated a lot!!!
Thanks in advance
ps: i found this script to hover an object label
I simply want it to say the username from smartfox login
http://www.unifycommunity.com/wiki/index.php?title=ObjectLabel
Hovering Usernames
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
thanks Thomas
thanks Thomas! but the post there didnt do the trick lol
so I'm simplifying the question....
How do I retrieve the usernames from smartfox?
I have this:
But it gives me errors on the debug part :S
I really dont know where to go from here,
as I tried to understand all tuts and tricks
without results.
Can someone help me out I just want the username (from smartfox)
to display in a GUIText attached to the remotePlayer.
I managed to retrieve my own username btw that was easier but not what I wanted...
Boohoo my players have no Identity
Thank you so much in advance,
RemiX
1
so I'm simplifying the question....
How do I retrieve the usernames from smartfox?
I have this:
Code: Select all
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using SmartFoxClientAPI;
using SmartFoxClientAPI.Data;
public class NewBehaviourScript : MonoBehaviour {
public class User
{
private int id;
private string name;
private Hashtable variables;
private bool isSpec;
private bool isMod;
private int pId;
public User(int id, string name)
{
this.id = id;
this.name = name;
this.variables = new Hashtable();
this.isSpec = false;
this.isMod = false;
}
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Debug.Log=(user.GetName());
}
}
But it gives me errors on the debug part :S
I really dont know where to go from here,
as I tried to understand all tuts and tricks
without results.
Can someone help me out I just want the username (from smartfox)
to display in a GUIText attached to the remotePlayer.
I managed to retrieve my own username btw that was easier but not what I wanted...
Boohoo my players have no Identity
Thank you so much in advance,
RemiX
1
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Once you have the User object that the remote user avatar model represents, its as simple as to do a GetName() on that.
So you could e.g. query the API for the current rooms user list.
Something along the lines of
Hashtable users = room.GetUserList();
foreach (User u in users.Values)
Trace.WriteLine(u.GetName());
Now - the trick is then to figure out which avatar in the world is what User. You will need to keep track of the users Id - and correlate that with the info from the SFS API.
Once you got that - its as simple as to have a 3d text object attached to each model that moves with it - that you can then set to the name. Or maybe you can use a 2d text projected into the 2d screen space instead of the world.
Hope that helps you along
/Thomas
So you could e.g. query the API for the current rooms user list.
Something along the lines of
Hashtable users = room.GetUserList();
foreach (User u in users.Values)
Trace.WriteLine(u.GetName());
Now - the trick is then to figure out which avatar in the world is what User. You will need to keep track of the users Id - and correlate that with the info from the SFS API.
Once you got that - its as simple as to have a 3d text object attached to each model that moves with it - that you can then set to the name. Or maybe you can use a 2d text projected into the 2d screen space instead of the world.
Hope that helps you along
/Thomas
Aaargh! I dont really get it
I started looking in the Network Controller script in the demo,
because ive seen that the username is used in there...
So I added a guitext to the remotePlayer prefab named unameit
and hooked into the OnPublicMessage lines.
So if there is something said the username should appear in the guitext ("atleast thats what i thought loool)
Nothing shows, I just cant figure it out.., noob as I am in CS and JS and SFS
Am I going in the right direction here?
Thanks docremix
ps: If you want to take a look....
http://kingdub.com/228616
I started looking in the Network Controller script in the demo,
because ive seen that the username is used in there...
So I added a guitext to the remotePlayer prefab named unameit
and hooked into the OnPublicMessage lines.
So if there is something said the username should appear in the guitext ("atleast thats what i thought loool)
Code: Select all
public void OnPublicMessage(string message, User fromUser, int roomId)
{
int userId = fromUser.GetId();
if (userId!=smartFoxClient.myUserId) { // If it's not myself
string mes = fromUser.GetName()+": "+message;
// here is what i tried
GameObject hovertje = GameObject.Find("remote_"+userId+"/unameit");
hovertje.guiText.text = (fromUser.GetName());
// Send chat message to the Chat Controller
SendMessage("AddChatMessage", mes);
//Find user object with such Id
GameObject user = GameObject.Find("remote_"+userId);
//If found - send him bubble message
if (user) {
user.SendMessage("ShowBubble", mes);
}
Nothing shows, I just cant figure it out.., noob as I am in CS and JS and SFS
Am I going in the right direction here?
Thanks docremix
ps: If you want to take a look....
http://kingdub.com/228616
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
I give UP!
Thanks for your time Thomas, but I really can't get it to work
debug gives me nothing and all stutters as if there is something missing
and if it should work its only when something is said
why cant i just add a script to the remoteplayer prefab GuiText saying something like... here u get your smartfox client username?
I think its not of my programming level.., I quit.., give up... no identity for me avies
thanks a million anyways
debug gives me nothing and all stutters as if there is something missing
and if it should work its only when something is said
why cant i just add a script to the remoteplayer prefab GuiText saying something like... here u get your smartfox client username?
I think its not of my programming level.., I quit.., give up... no identity for me avies
thanks a million anyways
Return to “.Net / Unity3D API”
Who is online
Users browsing this forum: No registered users and 17 guests