Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

error CS1002: ; expected

Discussion in 'AR/VR (XR) Discussion' started by OpheliaHed, Aug 11, 2020.

  1. OpheliaHed

    OpheliaHed

    Joined:
    Aug 4, 2020
    Posts:
    10
    I am very very new to Unity and I don't know anything at all about coding. I'm trying to build a ar thing for my class and currently following this tutorial.



    Perhaps there's something in the code I did wrong or perhaps the code is simply just old? I'm using the latest version of Unity 2020.

    Here's the code I copied from the tutorial. Thanks for the help!
    upload_2020-8-11_15-29-53.png
     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Line 38: You need to add a semi-colon to the end. All statements in C# must be terminated with a semi-colon.
     
  3. OpheliaHed

    OpheliaHed

    Joined:
    Aug 4, 2020
    Posts:
    10
    thank you so much for the help!
     
  4. OBEZYOSEF

    OBEZYOSEF

    Joined:
    Mar 18, 2021
    Posts:
    1
    I can't find the except ;

    here is my code


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class OtomatikMap : MonoBehaviour
    {
    public List<GameObject> mapler;
    public int KacMapGelsin;
    private float m_LastPos;
    void Start()
    {
    for (int i = 0; i < KacMapGelsin; i++)
    {
    int newid = i;
    int RandomMapver = Random.Range(0, mapler.Count);
    GameObject newMap = Instantiate(mapler[RandomMapver]);
    if (newid == 0)
    {
    Debug.log("aa");
    newMap.transform.position = new Vector3(0, 0, 0);
    }
    esle {
    newMap.transform.position = new Vector3(m_LastPos + 17.76f, 0, 0);
    Debug.log("aa");
    }
    m_LastPos = newMap.transform.position.x;
    }
    }


    }
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  6. Nasser2021

    Nasser2021

    Joined:
    Jun 26, 2021
    Posts:
    1
    Hi guys can someone help me it says ; expected in line 12

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class ObjectPool : MonoBehaviour
    {
    public static ObjectPool instance;

    private List<GameObject> pooledObjects = new List<GameObject>();
    private int amountToPool = 20

    [SerializeField] private GameObject bulletPrefab;


    private void Awake()
    {
    if (instance == null)
    {
    instance = this;
    }
    }


    void Start()
    {
    for (int i = 0; i < amountToPool; i++)
    {
    GameObject obj = Instantiate(bulletPrefab);
    obj.SetActive(false);
    pooledObject.Add(obj);
    }
    }

    public GameObject GetPooledObject()
    {
    for (int i = 0; i < pooledObject.Count; i++)
    {
    if (!pooledObjects.activeInHierarchy)
    {
    return pooledObjects;
    }
    }
    }
    }
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @Nasser2021 Welcome to the forums! Please take a few minutes to see how others on the forum post their code so we can read the line numbers using Code Tags. But just as the error says, you are missing a ; on line 12. I'm guessing that's this line, since it's missing that character:

    private int amountToPool = 20

    should be

    private int amountToPool = 20;
     
  8. Vanshikha

    Vanshikha

    Joined:
    Mar 15, 2022
    Posts:
    1
    please help me out i just cant find the expect; plz resolve this

    using System;
    using System.Collections.Generic;
    using UnityEditor.ShaderGraph;
    using Unity Engine.Ui;
    using UnityEngine.Rendering;
    using UnityEngine.Rendering.Universal;
    using UnityEditor.Rendering.Universal;
    using Data.Util;
    using UnityEditor.ShaderGraph.Internal;
    namespace UnityEditor.Experimental.Rendering.Universal
    {
    [Serializable]
    [FormerName("UnityEditor.Experimental.Rendering.LWRP.LightWeightSpriteUnlitSubShader")]
    class UniversalSpriteUnlitSubShader : ISpriteUnlitSubShader
    {
    #region Passes
    ShaderPass m_UnlitPass = new ShaderPass
    {
    // Definition
    referenceName = "SHADERPASS_SPRITEUNLIT",
    passInclude = "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/SpriteUnlitPass.hlsl",
    varyingsInclude = "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/Varyings.hlsl",
    useInPreview = true,
    // Port mask
    vertexPorts = new List<int>()
    {
    SpriteUnlitMasterNode.PositionSlotId,
    SpriteUnlitMasterNode.VertNormalSlotId,
    SpriteUnlitMasterNode.VertTangentSlotId
    },
    pixelPorts = new List<int>
    {
    SpriteUnlitMasterNode.ColorSlotId,
    },
    // Required fields
    requiredAttributes = new List<string>()
    {
    "Attributes.color",
    "Attributes.uv0",
    },
    requiredVaryings = new List<string>()
    {
    "Varyings.color",
    "Varyings.texCoord0",
    },

    // Pass setup
    includes = new List<string>()
    {
    "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl",
    "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl",
    "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl",
    "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl",
    },
    pragmas = new List<string>()
    {
    "prefer_hlslcc gles",
    "exclude_renderers d3d11_9x",
    "target 2.0",
    },
    keywords = new KeywordDescriptor[]
    {
    s_ETCExternalAlphaKeyword,
    },
    };
    #endregion
    #region Keywords
    static KeywordDescriptor s_ETCExternalAlphaKeyword = new KeywordDescriptor()
    {
    displayName = "ETC External Alpha",
    referenceName = "ETC1_EXTERNAL_ALPHA",
    type = KeywordType.Boolean,
    definition = KeywordDefinition.MultiCompile,
    scope = KeywordScope.Global,
    };
    #endregion
    public int GetPreviewPassIndex() { return 0; }
    private static ActiveFields GetActiveFieldsFromMasterNode(SpriteUnlitMasterNode masterNode, ShaderPass pass)
    {
    var activeFields = new ActiveFields();
    var baseActiveFields = activeFields.baseInstance;
    // Graph Vertex
    if(masterNode.IsSlotConnected(SpriteUnlitMasterNode.PositionSlotId) ||
    masterNode.IsSlotConnected(SpriteUnlitMasterNode.VertNormalSlotId) ||
    masterNode.IsSlotConnected(SpriteUnlitMasterNode.VertTangentSlotId))
    {
    baseActiveFields.Add("features.graphVertex");
    }
    // Graph Pixel (always enabled)
    baseActiveFields.Add("features.graphPixel");
    baseActiveFields.Add("SurfaceType.Transparent");
    baseActiveFields.Add("BlendMode.Alpha");
    return activeFields;
    }
    private static bool GenerateShaderPass(SpriteUnlitMasterNode masterNode, ShaderPass pass, GenerationMode mode, ShaderGenerator result, List<string> sourceAssetDependencyPaths)
    {
    UniversalShaderGraphUtilities.SetRenderState(SurfaceType.Transparent, AlphaMode.Alpha, true, ref pass);
    // apply master node options to active fields
    var activeFields = GetActiveFieldsFromMasterNode(masterNode, pass);
    // use standard shader pass generation
    return ShaderGraph.GenerationUtils.GenerateShaderPass(masterNode, pass, mode, activeFields, result, sourceAssetDependencyPaths,
    UniversalShaderGraphResources.s_Dependencies, UniversalShaderGraphResources.s_ResourceClassName, UniversalShaderGraphResources.s_AssemblyName);
    }
    public string GetSubshader(IMasterNode masterNode, GenerationMode mode, List<string> sourceAssetDependencyPaths = null)
    {
    if (sourceAssetDependencyPaths != null)
    {
    // LightWeightSpriteUnlitSubShader.cs
    sourceAssetDependencyPaths.Add(AssetDatabase.GUIDToAssetPath("3ef30c5c1d5fc412f88511ef5818b654"));
    }
    // Master Node data
    var unlitMasterNode = masterNode as SpriteUnlitMasterNode;
    var subShader = new ShaderGenerator();
    subShader.AddShaderChunk("SubShader", true);
    subShader.AddShaderChunk("{", true);
    subShader.Indent();
    {
    var surfaceTags = ShaderGenerator.BuildMaterialTags(SurfaceType.Transparent);
    var tagsBuilder = new ShaderStringBuilder(0);
    surfaceTags.GetTags(tagsBuilder, "UniversalPipeline");
    subShader.AddShaderChunk(tagsBuilder.ToString());
    GenerateShaderPass(unlitMasterNode, m_UnlitPass, mode, subShader, sourceAssetDependencyPaths);
    }
    subShader.Deindent();
    subShader.AddShaderChunk("}", true);
    return subShader.GetShaderString(0);
    }
    public bool IsPipelineCompatible(RenderPipelineAsset renderPipelineAsset)
    {
    return renderPipelineAsset is UniversalRenderPipelineAsset;
    }
    public UniversalSpriteUnlitSubShader() { }
    }
    }