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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

I have a parsing error in my script

Discussion in 'Scripting' started by Michaelm9945, Mar 10, 2015.

  1. Michaelm9945

    Michaelm9945

    Joined:
    Feb 20, 2015
    Posts:
    27
    This is the warning that keeps showing up everytime I try to build my player

    "ssets/OVR/Scripts/Util/OVRUGUI.cs(293,8): error CS8025: Parsing error"

    and this is my script



    Code (CSharp):
    1. ************************************************************************************
    2.  
    3. Copyright   :   Copyright 2014 Oculus VR, LLC. All Rights reserved.
    4.  
    5. Licensed under the Oculus VR Rift SDK License Version
    6.  
    7. 3.2 (the "License");
    8. you may not use the Oculus VR Rift SDK except in compliance with the License,
    9. which is provided at the time of installation or download, or which
    10. otherwise accompanies this software in either electronic or hard copy form.
    11.  
    12. You may obtain a copy of the License at
    13.  
    14. http://www.oculusvr.com/licenses/LICENSE-3.2
    15.  
    16. Unless required by applicable law or agreed to in writing, the Oculus VR SDK
    17. distributed under the License is distributed on an "AS IS" BASIS,
    18. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    19. See the License for the specific language governing permissions and
    20. limitations under the License.
    21.  
    22. ************************************************************************************/
    23.  
    24. // Use the Unity new GUI with Unity 4.6 or above.
    25. #if UNITY_4_6 || UNITY_5_0
    26. #define USE_NEW_GUI
    27. #endif
    28.  
    29. using UnityEngine;
    30. #if USE_NEW_GUI
    31. using UnityEngine.UI;
    32. # endif
    33. using System.Collections;
    34.  
    35. //-------------------------------------------------------------------------------------
    36. /// <summary>
    37. /// Class for Unity new GUI built in 4.6
    38. /// </summary>
    39. public class OVRUGUI
    40. {
    41.     #if USE_NEW_GUI
    42.  
    43.     #region UIGameObject
    44.     private static GameObject NewGUIManager;
    45.     private static GameObject RiftPresent;
    46.     private static GameObject LowPersistence;
    47.     private static GameObject VisionMode;
    48.     private static GameObject FPS;
    49.     private static GameObject Prediction;
    50.     private static GameObject IPD;
    51.     private static GameObject FOV;
    52.     private static GameObject Height;
    53.     private static GameObject SpeedRotationMutipler;
    54.     private static GameObject DeviceDetection;
    55.     private static GameObject ResolutionEyeTexture;
    56.     private static GameObject Latencies;
    57.     #endregion
    58.  
    59.     #region VRVariables
    60.     [HideInInspector]
    61.     public static string strRiftPresent = null;
    62.     [HideInInspector]
    63.     public static string strLPM = null; //"LowPersistenceMode: ON";
    64.     [HideInInspector]
    65.     public static string strVisionMode = null;//"Vision Enabled: ON";
    66.     [HideInInspector]
    67.     public static string strFPS = null;//"FPS: 0";
    68.     [HideInInspector]
    69.     public static string strIPD = null;//"IPD: 0.000";
    70.     [HideInInspector]
    71.     public static string strPrediction = null;//"Pred: OFF";
    72.     [HideInInspector]
    73.     public static string strFOV = null;//"FOV: 0.0f";
    74.     [HideInInspector]
    75.     public static string strHeight = null;//"Height: 0.0f";
    76.     [HideInInspector]
    77.     public static string strSpeedRotationMultipler = null;//"Spd. X: 0.0f Rot. X: 0.0f";
    78.     [HideInInspector]
    79.     public static OVRPlayerController PlayerController = null;
    80.     [HideInInspector]
    81.     public static OVRCameraRig CameraController = null;
    82.     //[HideInInspector]
    83.     //public static string strDeviceDetection = null;// Device attach / detach
    84.     [HideInInspector]
    85.     public static string strResolutionEyeTexture = null;// "Resolution : {0} x {1}"
    86.     [HideInInspector]
    87.     public static string strLatencies = null;// Device attach / detach
    88.     #endregion
    89.  
    90.     [HideInInspector]
    91.     public static bool InitUIComponent = false;
    92.     private static float offsetY = 55.0f;
    93.     private static bool isInited = false;
    94.     private static int numOfGUI = 0;
    95.     private static GameObject text;
    96.  
    97.     /// <summary>
    98.     /// It's for rift present GUI
    99.     /// </summary>
    100.     public static void RiftPresentGUI(GameObject GUIMainOBj)
    101.     {
    102.         RiftPresent = ComponentComposition(RiftPresent);
    103.         RiftPresent.transform.parent = GUIMainOBj.transform;
    104.         RiftPresent.name = "RiftPresent";
    105.         RectTransform r = RiftPresent.GetComponent<RectTransform>();
    106.         r.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
    107.         r.localScale = new Vector3(1.0f, 1.0f, 1.0f);
    108.         r.localEulerAngles = Vector3.zero;
    109.  
    110.         Text t = RiftPresent.GetComponentInChildren<Text>();
    111.         t.text = strRiftPresent;
    112.         t.fontSize = 20;      
    113.     }
    114.  
    115.     /// <summary>
    116.     /// It's for rift present GUI
    117.     /// </summary>
    118.     public static void UpdateGUI()
    119.     {
    120.         if (InitUIComponent && !isInited)
    121.         {
    122.             InitUIComponents();
    123.         }
    124.  
    125.         UpdateVariable();
    126.     }
    127.  
    128.  
    129.     /// <summary>
    130.     /// Update VR Variables
    131.     /// </summary>
    132.     static void UpdateVariable()
    133.     {
    134.         NewGUIManager.transform.localPosition = new Vector3(0.0f, 100.0f, 0.0f);
    135.  
    136.         if (!string.IsNullOrEmpty(strLPM))
    137.             LowPersistence.GetComponentInChildren<Text>().text = strLPM;
    138.         if (!string.IsNullOrEmpty(strVisionMode))
    139.             VisionMode.GetComponentInChildren<Text>().text = strVisionMode;
    140.         if (!string.IsNullOrEmpty(strFPS))
    141.              FPS.GetComponentInChildren<Text>().text = strFPS;
    142.         if (!string.IsNullOrEmpty(strPrediction))
    143.             Prediction.GetComponentInChildren<Text>().text = strPrediction;
    144.         if (!string.IsNullOrEmpty(strIPD))
    145.             IPD.GetComponentInChildren<Text>().text = strIPD;
    146.         if (!string.IsNullOrEmpty(strFOV))
    147.             FOV.GetComponentInChildren<Text>().text = strFOV;
    148.         if (!string.IsNullOrEmpty(strResolutionEyeTexture))
    149.             ResolutionEyeTexture.GetComponentInChildren<Text>().text = strResolutionEyeTexture;
    150.         if (!string.IsNullOrEmpty(strLatencies))
    151.             Latencies.GetComponentInChildren<Text>().text = strLatencies;
    152.  
    153.         if (PlayerController != null)
    154.         {
    155.             if (!string.IsNullOrEmpty(strHeight))
    156.                 Height.GetComponentInChildren<Text>().text = strHeight;
    157.             if (!string.IsNullOrEmpty(strSpeedRotationMultipler))
    158.                 SpeedRotationMutipler.GetComponentInChildren<Text>().text = strSpeedRotationMultipler;
    159.         }
    160.     }
    161.  
    162.     /// <summary>
    163.     /// Initialize UI GameObjects
    164.     /// </summary>
    165.     static void InitUIComponents()
    166.     {
    167.         float posY = 0.0f;
    168.         int fontSize = 20;
    169.  
    170.         NewGUIManager = new GameObject();
    171.         NewGUIManager.name = "GUIManager";
    172.         NewGUIManager.transform.parent = GameObject.Find("OVRGUIMain").transform;
    173.         NewGUIManager.transform.localPosition = Vector3.zero;
    174.         NewGUIManager.transform.localEulerAngles = Vector3.zero;
    175.         NewGUIManager.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
    176.        
    177.         // Print out for Low Persistence Mode
    178.         if (!string.IsNullOrEmpty(strLPM))
    179.         {          
    180.             LowPersistence = UIObjectManager(LowPersistence, "LowPersistence", posY -= offsetY, strLPM, fontSize);
    181.         }
    182.  
    183.         // Print out for VisionMode
    184.         if (!string.IsNullOrEmpty(strVisionMode))
    185.         {
    186.             VisionMode = UIObjectManager(VisionMode, "VisionMode", posY -= offsetY, strVisionMode, fontSize);
    187.         }
    188.  
    189.         // Print out for FPS
    190.         if (!string.IsNullOrEmpty(strFPS))
    191.         {
    192.             FPS = UIObjectManager(FPS, "FPS", posY -= offsetY, strFPS, fontSize);
    193.         }
    194.  
    195.         // Print out for Prediction
    196.         if (!string.IsNullOrEmpty(strPrediction))
    197.         {
    198.             Prediction = UIObjectManager(Prediction, "Prediction", posY -= offsetY, strPrediction, fontSize);
    199.         }
    200.  
    201.         // Print out for IPD
    202.         if (!string.IsNullOrEmpty(strIPD))
    203.         {
    204.             IPD = UIObjectManager(IPD, "IPD", posY -= offsetY, strIPD, fontSize);
    205.         }
    206.  
    207.         // Print out for FOV
    208.         if (!string.IsNullOrEmpty(strFOV))
    209.         {
    210.             FOV = UIObjectManager(FOV, "FOV", posY -= offsetY, strFOV, fontSize);
    211.         }
    212.  
    213.         if (PlayerController != null)
    214.         {
    215.             // Print out for Height
    216.             if (!string.IsNullOrEmpty(strHeight))
    217.             {
    218.                 Height = UIObjectManager(Height, "Height", posY -= offsetY, strHeight, fontSize);
    219.             }
    220.  
    221.             // Print out for Speed Rotation Multiplier
    222.             if (!string.IsNullOrEmpty(strSpeedRotationMultipler))
    223.             {
    224.                 SpeedRotationMutipler = UIObjectManager(SpeedRotationMutipler, "SpeedRotationMutipler", posY -= offsetY, strSpeedRotationMultipler, fontSize);
    225.             }
    226.         }
    227.  
    228.         // Print out for Resoulution of Eye Texture
    229.         if (!string.IsNullOrEmpty(strResolutionEyeTexture))
    230.         {
    231.             ResolutionEyeTexture = UIObjectManager(ResolutionEyeTexture, "Resolution", posY -= offsetY, strResolutionEyeTexture, fontSize);
    232.         }
    233.  
    234.         // Print out for Latency
    235.         if (!string.IsNullOrEmpty(strLatencies))
    236.         {
    237.             Latencies = UIObjectManager(Latencies, "Latency", posY -= offsetY, strLatencies, 17);
    238.             posY = 0.0f;
    239.         }
    240.  
    241.         InitUIComponent = false;
    242.         isInited = true;
    243.  
    244.     }
    245.  
    246.     static GameObject UIObjectManager(GameObject gameObject, string name, float posY, string text, int fontSize)
    247.     {
    248.         gameObject = ComponentComposition(gameObject);
    249.         gameObject.name = name;
    250.         gameObject.transform.parent = NewGUIManager.transform;
    251.  
    252.         RectTransform r = gameObject.GetComponent<RectTransform>();
    253.         r.localPosition = new Vector3(0.0f, posY -= offsetY, 0.0f);
    254.  
    255.         Text t = gameObject.GetComponentInChildren<Text>();
    256.         t.text = text;
    257.         t.fontSize = fontSize;
    258.         gameObject.transform.localEulerAngles = Vector3.zero;
    259.  
    260.         r.localScale = new Vector3(1.0f, 1.0f, 1.0f);
    261.  
    262.         return gameObject;
    263.  
    264.     }
    265.    
    266.     /// <summary>
    267.     /// Component composition
    268.     /// </summary>
    269.     /// <returns> Composed game object. </returns>
    270.     static GameObject ComponentComposition(GameObject GO)
    271.     {
    272.         GO = new GameObject();
    273.         GO.AddComponent<RectTransform>();
    274.         GO.AddComponent<CanvasRenderer>();
    275.         GO.AddComponent<Image>();
    276.         GO.GetComponent<RectTransform>().sizeDelta = new Vector2(350f, 50f);
    277.         GO.GetComponent<Image>().color = new Color(7f / 255f, 45f / 255f, 71f / 255f, 200f / 255f);
    278.  
    279.         text = new GameObject();
    280.         text.AddComponent<RectTransform>();
    281.         text.AddComponent<CanvasRenderer>();
    282.         text.AddComponent<Text>();
    283.         text.GetComponent<RectTransform>().sizeDelta = new Vector2(350f, 50f);
    284.         text.GetComponent<Text>().font = (Font)Resources.Load("DINPro-Bold");
    285.         new object { {new object{            
    286.  
    287.                     text.transform.parent  .transform}
    288.                 .name = "TextBox"}
    289.  
    290.         }
    291.    
    292.    
    293. #endif
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Jumping to the end of your file, it looks like you are missing some ending curly brackets.
     
  3. Zaladur

    Zaladur

    Joined:
    Oct 20, 2012
    Posts:
    392
    What DanielQuick said. Generally, if you get a parsing error pointing to the last line of the file, you have mismatched curly braces. Looks like you just need to close your class on line 291-292.
     
  4. Michaelm9945

    Michaelm9945

    Joined:
    Feb 20, 2015
    Posts:
    27
    I'm not smart when it comes to Scripts. Can you copy and paste my whole script with the correct changes?

    Thanks
     
  5. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    I somehow doubt that Oculus is publishing code that doesn't compile so I would just pull from the original source again.

    Also, generally speaking, requests for "fix my 290 line script for me" will be met with responses of "no" :)
     
  6. Michaelm9945

    Michaelm9945

    Joined:
    Feb 20, 2015
    Posts:
    27
    Did I say "fix my 290 Line script?" No, I believe I did not. I have a problem with the last couple lines in my script, that I need fixing. I'm asking for someone to copy and paste the whole script that I mentioned at the beginning of my post and just make a couple correct changes for the last couple lines. It's no more than 2 minute work.

    It's easier for me to be giving my script with a couple changes to it, rather than be giving a complicated explanation of what needs done.

    I've already made my game and I just need to build it, but there's a compiling error that's stopping me from doing that.
     
  7. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Ok, so we're getting testy. That's fine I guess.

    Yes you did say fix your script. Your exact words were "copy and paste my whole script with the correct changes". What part of that is unclear?

    And you haven't made anything except a copy-pasted piece of code that doesn't compile.

    The explanation isn't complicated. Every open curly bracket needs a corresponding closing one. Go find which ones are missing.
     
    Deleted User likes this.
  8. Michaelm9945

    Michaelm9945

    Joined:
    Feb 20, 2015
    Posts:
    27
    I don't need someone to write my script for me. Just copy and paste it with the changes. Its not that hard

    I previously said "I'm not smart when it comes to scripts." So, that's why I don't really understand
     
  9. Michaelm9945

    Michaelm9945

    Joined:
    Feb 20, 2015
    Posts:
    27
    I've added curly brackets and anything I can think of to fix this problem, but nothing seems to work. That's why I need more than just an explanation. I need someone to show me what I'm doing wrong
     
  10. Deleted User

    Deleted User

    Guest

    Like @KelsoMRK said, this script wasn't written by you so why don't you go back to where you found it and copy it again?
    Also, you are asking people to fix your script for you when you say "copy & paste it with the changes".

    A parsing error usually means you're missing a } bracket. Try adding a couple } brackets at the end of the script.
     
  11. Michaelm9945

    Michaelm9945

    Joined:
    Feb 20, 2015
    Posts:
    27
    I tried to search for the OVRUGUI.cs script again, so I can see how it originally looked like before the errors. I can't seem, to find the script
     
  12. lupo316

    lupo316

    Joined:
    Nov 29, 2015
    Posts:
    1
    I just began in Unity yesterday evening with about 3 hours of online tutorials for beginners. I too ran into this error, and read closely where it identifies in the error what line I can find the code on to correct the problem. By simply adding } at the end of the script, and removing one unnecessary { I was able to fix the problem by reading my own script in detail while simultaneously using the advise found here. In the process, seeing someone asking everyone else to fix the code with attitude was absurd. Just a quick thanks from this newbie to the rest of the community for being patient and explaining the issue in detail above. Sorry to see the person asking the question turned ridiculous.