Search Unity

Help with CS0101

Discussion in 'Scripting' started by darkben, Jan 9, 2011.

  1. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    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:

    http://www.unifycommunity.com/wiki/i...rtFox_tutorial

    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.
     
    Last edited: Jan 9, 2011
  2. Chris-Sinclair

    Chris-Sinclair

    Joined:
    Jun 14, 2010
    Posts:
    1,326
    Everything looks fine at first glance. What is the error message that you're getting?
     
  3. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    The namespace global:: already contains a definition for 'SmartFox'
     
  4. Chris-Sinclair

    Chris-Sinclair

    Joined:
    Jun 14, 2010
    Posts:
    1,326
    Likely it means you already have another class/script called SmartFox elsewhere. Rename this static class or the other script.
     
  5. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
  6. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    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'
     
  7. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
  8. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    normally i wouldn't, but i thought the scripting forum would be better
     
  9. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    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
     
  10. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    OK, that problem has gone now, no idea how, i reloaded the project, except now i have animation problems...
     
  11. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    I now have a playable version but there are still some error messages, I will look into it, but I'm going to test the cross LAN networking first
     
  12. RedMars

    RedMars

    Joined:
    Sep 29, 2013
    Posts:
    1
    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.
     
  13. Deepschalappatta

    Deepschalappatta

    Joined:
    Jul 27, 2013
    Posts:
    8
    I got this error... I already deleted the SmartFox script from the Network folder...when iam trying to move a player it display some errors like

    "Unity Web Player [version: Unity 4.3.3f1_c8ca9b6b9936]

    mono-1-vc.dll caused an Access Violation (0xc0000005)
    in module mono-1-vc.dll at 001b:045d651e."

    also stuck the demo.... how to solve this problem.... thanks in advance