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

using System.Diagnostics.Eventing.Reader error

Discussion in 'Scripting' started by yusefkerr, Sep 5, 2020.

  1. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Hello, I'm trying to build my project for PC, and I get the following errors:

    ---
    using System.Diagnostics.Eventing.Reader;
    Assets\Scripts\GameManager.cs(6,26): error CS0234: The type or namespace name 'Eventing' does not exist in the namespace 'System.Diagnostics' (are you missing an assembly reference?)

    Error building Player because scripts had compiler errors

    Build completed with a result of 'Failed'
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)

    UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x0027c] in <d1bec46880064709a5e713ad543e6d96>:0
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <d1bec46880064709a5e713ad543e6d96>:0
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)

    ---
    I don't recognise any of this, and so I assume that it's due to the line
    "using System.Diagnostics.Eventing.Reader;"
    in my GameManager script, but I don't have any idea how to fix the error. It's stopping me from building my game, so any suggestions?
     
  2. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Code (CSharp):
    1. replace smileys with :P please
     
    mimuraunity likes this.
  3. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    Post the contents of your GameManager script for us (use code tags) so we can see what's going on. Kinda hard to tell what's happening without seeing the code. :p
     
  4. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Thanks for the reply, I commented the line out, and that enabled the project to build. I don't remember adding the line in at all, so I'm guessing that it was added automatically at some point.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UIElements;
    5. using UnityEngine.EventSystems;
    6. //using System.Diagnostics.Eventing.Reader;
    7.  
    8. public static class GameManager
    9. {
    10.     #region fields
    11.     [SerializeField]
    12.     static List<GameObject> positions = new List<GameObject>();
    13.  
    14.     #endregion
    15.  
    16.     #region Properties
    17.     public static List<GameObject> Positions
    18.     {
    19.         get { return positions; }
    20.     }
    21.  
    22.     #endregion
    23.  
    24.     public static void Initialize()
    25.     {
    26.         //add all pos gameobjections to a list "positions"
    27.         foreach (GameObject go in GameObject.FindGameObjectsWithTag("Pos"))
    28.         {
    29.             AddPosition(go);
    30.         }
    31.         //find the deck position and move it to the front of the list
    32.         for (int i = 0; i < positions.Count; i++)
    33.         {
    34.             if (positions[i].transform.position.z >= 0)
    35.             {
    36.                 GameObject temp = positions[i];
    37.                 positions.RemoveAt(i);
    38.                 positions.Insert(0, temp);
    39.             }
    40.         }
    41.     }
    42.  
    43.     //add the positions to a list based on their position in the x-axis (i.e. from left to right)
    44.     public static void AddPosition(GameObject go)
    45.     {
    46.         if (positions.Count == 0)
    47.         {
    48.             positions.Add(go);
    49.         }
    50.         else
    51.         {
    52.             int addLocation = 0;
    53.             while (addLocation < positions.Count && positions[addLocation].transform.position.x < go.transform.position.x)
    54.             {
    55.                 addLocation++;
    56.             }
    57.             positions.Insert(addLocation, go);
    58.         }
    59.     }
    60.  
    61.     public static bool IsPointerOverUIObject()
    62.     {
    63.         PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current);
    64.         eventDataCurrentPosition.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
    65.         List<RaycastResult> results = new List<RaycastResult>();
    66.         EventSystem.current.RaycastAll(eventDataCurrentPosition, results);
    67.  
    68.         for (int i = 0; i < results.Count; i++)
    69.         {
    70.             //Debug.Log("one object found was" + results[i]);
    71.  
    72.             if (results[i].gameObject.tag == "UIBlocker")
    73.             {
    74.                 return true;
    75.             }
    76.         }
    77.         return false;
    78.     }  
    79.  
    80. }
    81.    
    82.