How to fix error CS1056 (and other ones) in parallax script,Why do I get error cs1056

Hi all! I was going to to add a Parallax script in 2d game:

 [ExecuteInEditMode]
  public class ParallaxBackground : MonoBehaviour
  {
    public ParallaxCamera parallaxCamera;
    List<ParallaxLayer> parallaxLayers = new List<ParallaxLayer>();
   
    void Start()
    {
        if (parallaxCamera == null)
          parallaxCamera = Camera.main.GetComponent<ParallaxCamera>();
        if (parallaxCamera != null)
          parallaxCamera.onCameraTranslate += Move;
        SetLayers();
    }
   
    void SetLayers()
    {
        parallaxLayers.Clear();
        for (int i = 0; i < transform.childCount; i++)
        {
            ParallaxLayer layer = transform.GetChild(i).GetComponent<ParallaxLayer>();
   
            if (layer != null)
            {
                layer.name = "Layer-" + i;
                parallaxLayers.Add(layer);
            }
        }
      }
      void Move(float delta)
      {
          foreach (ParallaxLayer layer in parallaxLayers)
        {
            layer.Move(delta);
        }
    }
  }

and i got a bunch of errors, here they are:

Assets\scripts\Parallax\ParallaxBackground.cs(23,40): error CS1002: ; expected Assets\scripts\Parallax\ParallaxBackground.cs(23,40): error CS1056: Unexpected character ‘' Assets\scripts\Parallax\ParallaxBackground.cs(23,41): error CS1056: Unexpected character '’ Assets\scripts\Parallax\ParallaxBackground.cs(23,51): error CS1056: Unexpected character ‘' Assets\scripts\Parallax\ParallaxBackground.cs(23,52): error CS1056: Unexpected character '’ Assets\scripts\Parallax\ParallaxBackground.cs(23,53): error CS1003: Syntax error, ‘,’ expected Assets\scripts\Parallax\ParallaxBackground.cs(23,60): error CS1026: ) expected Assets\scripts\Parallax\ParallaxBackground.cs(23,65): error CS1002: ; expected Assets\scripts\Parallax\ParallaxBackground.cs(23,65): error CS1513: } expected Assets\scripts\Parallax\ParallaxBackground.cs(25,49): error CS1056: Unexpected character ‘' Assets\scripts\Parallax\ParallaxBackground.cs(25,51): error CS1002: ; expected Assets\scripts\Parallax\ParallaxBackground.cs(25,60): error CS1002: ; expected Assets\scripts\Parallax\ParallaxBackground.cs(25,60): error CS1056: Unexpected character '’ Assets\scripts\Parallax\ParallaxBackground.cs(25,61): error CS1056: Unexpected character ‘$’

how can i fix them?

,Hi all! I was going to to add a Parallax script in 2d game:

[ExecuteInEditMode]
 public class ParallaxBackground : MonoBehaviour
 {
   public ParallaxCamera parallaxCamera;
   List<ParallaxLayer> parallaxLayers = new List<ParallaxLayer>();
  
   void Start()
   {
       if (parallaxCamera == null)
         parallaxCamera = Camera.main.GetComponent<ParallaxCamera>();
       if (parallaxCamera != null)
         parallaxCamera.onCameraTranslate += Move;
       SetLayers();
   }
  
   void SetLayers()
   {
       parallaxLayers.Clear();
       for (int i = 0; i < transform.childCount; i++)
       {
           ParallaxLayer layer = transform.GetChild(i).GetComponent<ParallaxLayer>();
  
           if (layer != null)
           {
               layer.name = "Layer-" + i;
               parallaxLayers.Add(layer);
           }
       }
     }
     void Move(float delta)
     {
         foreach (ParallaxLayer layer in parallaxLayers)
       {
           layer.Move(delta);
       }
   }
 }

and i got a bunch of errors, here they are:

Assets\scripts\Parallax\ParallaxBackground.cs(23,40): error CS1002: ; expected Assets\scripts\Parallax\ParallaxBackground.cs(23,40): error CS1056: Unexpected character ‘' Assets\scripts\Parallax\ParallaxBackground.cs(23,41): error CS1056: Unexpected character '’ Assets\scripts\Parallax\ParallaxBackground.cs(23,51): error CS1056: Unexpected character ‘' Assets\scripts\Parallax\ParallaxBackground.cs(23,52): error CS1056: Unexpected character '’ Assets\scripts\Parallax\ParallaxBackground.cs(23,53): error CS1003: Syntax error, ‘,’ expected Assets\scripts\Parallax\ParallaxBackground.cs(23,60): error CS1026: ) expected Assets\scripts\Parallax\ParallaxBackground.cs(23,65): error CS1002: ; expected Assets\scripts\Parallax\ParallaxBackground.cs(23,65): error CS1513: } expected Assets\scripts\Parallax\ParallaxBackground.cs(25,49): error CS1056: Unexpected character ‘' Assets\scripts\Parallax\ParallaxBackground.cs(25,51): error CS1002: ; expected Assets\scripts\Parallax\ParallaxBackground.cs(25,60): error CS1002: ; expected Assets\scripts\Parallax\ParallaxBackground.cs(25,60): error CS1056: Unexpected character '’ Assets\scripts\Parallax\ParallaxBackground.cs(25,61): error CS1056: Unexpected character ‘$’

how can i fix them?

This is why you should never copy code without reading/understanding it first…

if says: GetChild and childCount in your code. which is an issue with the unity-forum where in posts from before a certain time all hi or something was replaces by $$anonymous$$.

So it should say: GetChild and childCount instead.

Never use code by simply copypasting without reading it if you don’t know what it does. This can be dangerous for your computer.