So I am trying to fix the last part of this MMO tutorial I am doing. Some of the code beforehand in other scripts needed changing, and Unity has not accepted it, except for this last script which i cannot get to work.
The tutorial is here:
Unity defines the problem on line 7, where it says public static class SmartFox {
The script is here:
using UnityEngine;
using SmartFoxClientAPI;
// Statics for holding the connection to the SFS server end
// Can then be queried from the entire game to get the connection
public class SmartFox : MonoBehaviour
{
private static SmartFoxClient smartFox;
public static SmartFoxClient Connection
{
get { return smartFox; }
set { smartFox = value; }
}
public static bool IsInitialized() {
if ( smartFox != null ) {
return true;
}
return false;
}
}
any help would be appreciated, this is the final bug fix for the build
I am fairly new to unity and don’t have that much coding experience, so can’t really identify problems.
I have rejigged the folders, that changed something.
I named them both SmartFox, as they originally were named, then Unity told me to rename one of them. I did, and now the same problem lies in this script:
using UnityEngine;
using SmartFoxClientAPI;
// Statics for holding the connection to the SFS server end
// Can then be queried from the entire game to get the connection
public static class SmartFox {
private static SmartFoxClient smartFox;
public static SmartFoxClient Connection {
get { return smartFox; }
set { smartFox = value; }
}
public static bool IsInitialized() {
if ( smartFox != null ) {
return true;
}
return false;
}
}
line 7 again, the namespace ‘global::’ already contains a definition for ‘SmartFox’
I tried changing some names and I don’t get that error any more, but i get these three:
Assets/network/NetworkTransform.cs(8,14): warning CS0659: `NetworkTransform’ overrides Object.Equals(object) but does not override Object.GetHashCode()
Assets/Scripts/ChatController.cs(21,22): warning CS0414: The private field `ChatController.sendingMessage’ is assigned but its value is never used
Assets/Scripts/gui_Game.cs(15,17): warning CS0414: The private field `gui_Game.myId’ is assigned but its value is never used
I deleted the SmartFox script from the Network folder and this seemed to clear up everything. Apparently the two scripts are identical it’s just that the demo stuck it in the network folder and the tutorial has it outside.