Search Unity

Error CS1003

Discussion in 'UNet' started by unity_4binor, Dec 16, 2021.

?

How to fix this error?

  1. I don't know

    100.0%
  2. I don't know

    100.0%
Multiple votes are allowed.
  1. unity_4binor

    unity_4binor

    Joined:
    Dec 9, 2021
    Posts:
    17
    Hello dear Unity users! I ask you to help me with the error (27,9): error CS1003: Syntax error, ',' expected
    here is the script:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ChatLog : MonoBehaviour
    5. {
    6.     private GameManager gameManage;
    7.     public string Log;
    8.     public Color TextColor = Color.white;
    9.     public bool ActiveChat;
    10.     public float ShowTextDuration = 5;
    11.     float timeTemp;
    12.  
    13.     void Start ()
    14.     {
    15.         gameManage = (GameManager)GameObject.FindObjectOfType (typeof(GameManager));
    16.     }
    17.  
    18.     public void AddLog (string text)
    19.     {
    20.         if (Network.isClient || Network.isServer) {
    21.             if (GetComponent<NetworkView>())
    22.                 GetComponent<NetworkView>().RPC ("SendChatMessage", RPCMode.All, text);
    23.         }
    24.  
    25.     }
    26.  
    27.     [Unity Multiplayer]
    28.     void SendChatMessage (string text)
    29.     {
    30.         Log += "\n" + text;
    31.         timeTemp = Time.time;
    32.         showLog = true;
    33.     }
    34.  
    35.     bool showLog = false;
    36.  
    37.     void Update ()
    38.     {
    39.         if (!gameManage)
    40.             return;
    41.      
    42.         if (Input.GetKeyDown (KeyCode.Return)) {
    43.          
    44.             ActiveChat = !ActiveChat;
    45.             if (ActiveChat) {
    46.                 timeTemp = Time.time;
    47.                 showLog = true;
    48.             }
    49.         }
    50.         if (showLog) {
    51.             if (Time.time >= timeTemp + ShowTextDuration) {
    52.                 showLog = false;  
    53.             }
    54.         }
    55.  
    56.     }
    57.  
    58.     public void Clear ()
    59.     {
    60.         Log = string.Empty;
    61.     }
    62.  
    63.     string chattext = "";
    64.  
    65.     void OnGUI ()
    66.     {
    67.         if (!gameManage || !gameManage.IsPlaying)
    68.             return;
    69.      
    70.         GUI.skin.label.fontSize = 17;
    71.         GUI.skin.label.normal.textColor = TextColor;
    72.         GUI.skin.label.alignment = TextAnchor.LowerLeft;
    73.      
    74.         if (showLog)
    75.             GUI.Label (new Rect (10, 10, Screen.width, 200), Log);
    76.      
    77.         if (ActiveChat) {
    78.             timeTemp = Time.time;
    79.             GUI.SetNextControlName ("Chattext");
    80.             chattext = GUI.TextField (new Rect (10, 210, 200, 20), chattext);
    81.          
    82.             if (Event.current != null && Event.current.keyCode == KeyCode.Return) {
    83.                 if (chattext != string.Empty) {
    84.                     AddLog ("<color=yellow>" + PlayerPrefs.GetString ("user_name") + " : </color>" + chattext);
    85.                     ActiveChat = false;
    86.                     chattext = string.Empty;
    87.                 }
    88.             }
    89.             GUI.FocusControl ("Chattext");
    90.         }
    91.      
    92.     }
    93. }
    94.  

    Error:
    Assets\Scripts\Components\ChatLog.cs(27,9): error CS1003: Syntax error, ',' expected
     
    Last edited: Dec 16, 2021
  2. unity_4binor

    unity_4binor

    Joined:
    Dec 9, 2021
    Posts:
    17
    Even when using RPC, an error pops up:error CS1001: Identifier expected entered like this: ["RPC"]
     
  3. unity_4binor

    unity_4binor

    Joined:
    Dec 9, 2021
    Posts:
    17
    I've already tried everything...
     
  4. unity_4binor

    unity_4binor

    Joined:
    Dec 9, 2021
    Posts:
    17
    Error on page 27
     
  5. unity_4binor

    unity_4binor

    Joined:
    Dec 9, 2021
    Posts:
    17
    Please help me with the error
     
  6. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,925
    Code (CSharp):
    1. [Unity Multiplayer]
    Pretty sure attributes don't have spaces in their names.
     
  7. unity_4binor

    unity_4binor

    Joined:
    Dec 9, 2021
    Posts:
    17
    There will still be an error if I enter [UnityMultiplayer] Instead of [Unity Multiplayer] there will be 111 more errors because the scripts are interconnected
     
  8. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    The forums are not here to help you solve hundreds of errors in your typing. It's too much to ask of other devs. The basics such as names of attributes should be retrieved from docs or tutorials.

    If devs wish to help then that's up to them but your problems will be seemingly never-ending because if someone fixes one thing for you, you'll move onto the next and say, "it didn't work".

    Wherever you got this code, please go back and check it against the original. If you see the above attribute somewhere else, then make sure you use it correctly. Correct C# syntax is something you need to learn.

    Final note: Please don't use the forums like a chat room, posting multiple one-line messages. You can edit your posts here, it's a forum.
     
    luke-unity likes this.
  9. unity_4binor

    unity_4binor

    Joined:
    Dec 9, 2021
    Posts:
    17
    I understand that 111 errors will not help me solve, but help with this one, which I asked a question about on the Unity forum
     
  10. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    And you got the help you asked for. What docs are you using and where did you see this attribute mentioned? Can you please post a link here.
     
  11. unity_4binor

    unity_4binor

    Joined:
    Dec 9, 2021
    Posts:
    17
    I use a ready-made Unity project to create my own link: UnitZ UNET (unity3ddd.ru)
     
  12. unity_4binor

    unity_4binor

    Joined:
    Dec 9, 2021
    Posts:
    17
    When I insert [UnityMultiplayer] (Without spaces), then I have 111 errors, I don't understand why it could be
     
  13. unity_4binor

    unity_4binor

    Joined:
    Dec 9, 2021
    Posts:
    17
    Ok,Thank you
     
    Last edited: Dec 16, 2021
  14. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    PLEASE STOP MAKING MULTIPLE POSTS. PLEASE EDIT YOUR POSTS. THIS IS NOT A WEB-CHAT.

    First, UNET was deprecated years ago. See here. I'm certainly not going to that link though. ;)

    Second, I'm not familiar with it anyway but I've never heard of that attribute so the answer to your question is, I'll move your post to the UNET forums here. Someone there might understand what the correct attribute is or advise you better.
     
  15. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    Sometimes errors cause other errors, because the compiler is confused. Sometimes errors stop other errors from appearing because the compiler stops before compiling the rest. Just because these other problems did not appear before, does not mean it was fine before.

    Always starts with the first error and work through them in order. Solving one error might solve one hundred, or it might cause further. Eventually you will have solved them all tho.

    If you wrote that code yourself you either introduced many many typos (like the space in the attribute), or if you downloaded the code as is.. you should probably give up on that source.
     
    luke-unity likes this.