Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Need help fixing Error CS0201 Only Assignment, call, increment, decrement.....

Discussion in 'Scripting' started by JBEDUnity, Jul 21, 2020.

  1. JBEDUnity

    JBEDUnity

    Joined:
    Jul 13, 2020
    Posts:
    23
    I get CS0201 Only assignment, call, increment, decrement, await, and new objct expressions can be used as a statement error on line 25.
    I've got no idea why.

    Code (CSharp):
    1. using Pixyz.Utils;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class InputTest : MonoBehaviour
    7. {
    8.     public GameObject[] objects;
    9.     public bool blActive;
    10.     public int aIndex;
    11.  
    12.     // Start is called before the first frame update
    13.     void Start()
    14.     {
    15.        
    16.     }
    17.  
    18.     // Update is called once per frame
    19.     void Update()
    20.     {
    21.         if (OVRInput.Get(OVRInput.Button.One))
    22.         {
    23.             for (int i = 0; i < objects.Length; i++)
    24.             {
    25.                 blActive != objects[i].activeSelf;
    26.                 objects[i].SetActive(blActive);
    27.                 Debug.LogError("You Pressed Button One");
    28.             }
    29.  
    30.         }
    31.     }
    32. }
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,741
    I think you meant = ! rather than !=
     
  3. JBEDUnity

    JBEDUnity

    Joined:
    Jul 13, 2020
    Posts:
    23
    Thanks, that's working.
     
  4. seejayjames

    seejayjames

    Joined:
    Jan 28, 2013
    Posts:
    685
    Yep, != is used as a comparison operator, not an assignment:
    if (myVar != 5) // do stuff