Наследование: UIBehaviour
Пример #1
0
 private void GetMouseHoverInfo(out bool is_hovering_screen, out bool is_hovering_button)
 {
     UnityEngine.EventSystems.EventSystem current = UnityEngine.EventSystems.EventSystem.current;
     if ((UnityEngine.Object)current == (UnityEngine.Object)null)
     {
         is_hovering_button = false;
         is_hovering_screen = false;
     }
     else
     {
         List <RaycastResult> list             = new List <RaycastResult>();
         PointerEventData     pointerEventData = new PointerEventData(current);
         pointerEventData.position = KInputManager.GetMousePos();
         current.RaycastAll(pointerEventData, list);
         bool flag  = false;
         bool flag2 = false;
         foreach (RaycastResult item in list)
         {
             if ((UnityEngine.Object)item.gameObject.GetComponent <OptionSelector>() != (UnityEngine.Object)null || ((UnityEngine.Object)item.gameObject.transform.parent != (UnityEngine.Object)null && (UnityEngine.Object)item.gameObject.transform.parent.GetComponent <OptionSelector>() != (UnityEngine.Object)null))
             {
                 flag  = true;
                 flag2 = true;
                 break;
             }
             if (HasParent(item.gameObject, base.gameObject))
             {
                 flag2 = true;
             }
         }
         is_hovering_screen = flag2;
         is_hovering_button = flag;
     }
 }
Пример #2
0
 public void Awake()
 {
     GameManager.Instance.CursorEnabled = false;
     this.canvas = GetComponent<Canvas>();
     this.eventSystem = FindObjectOfType<EventSystem>();
     this.wasCancelPressed = false;
 }
Пример #3
0
 private void Awake()
 {
     canvas           = gameObject.GetComponent <Canvas>();
     canvasScaler     = gameObject.GetComponent <CanvasScaler>();
     graphicRaycaster = gameObject.GetComponent <GraphicRaycaster>();
     eventSystem      = gameObject.GetComponent <UnityEngine.EventSystems.EventSystem>();
 }
Пример #4
0
 /// <summary>
 /// Init the UI Bridge, necessary
 /// </summary>
 public void InitBridge()
 {
     EventSystem = new GameObject("EventSystem").AddComponent<EventSystem>();
     EventSystem.gameObject.AddComponent<StandaloneInputModule>();
     #if !UNITY_5
     EventSystem.gameObject.AddComponent<TouchInputModule>();
     #endif
 }
Пример #5
0
 void Start()
 {
     _system = GetComponent<EventSystem>();
     if (_system == null)
     {
         Debug.LogError("Needs to be attached to the Event System component in the scene");
     }
 }
Пример #6
0
 void Start()
 {
     wallTempPrefab.SetActive(false);
     onWallCursor.SetActive(false);
     onWallCursor.SetActive(false);
     _eventSystem      = GameObject.Find("EventSystem").GetComponent <EventSystem>();
     wallPre           = wallPrefab;
     mat1              = wallMat;
     appendToLast.isOn = true;
     offset            = new Vector3(0, 0, 0);
 }
Пример #7
0
    bool ClickOnGUI(Vector3 mousePos)
    {
        UnityEngine.EventSystems.EventSystem ct
            = UnityEngine.EventSystems.EventSystem.current;


        if (ct.IsPointerOverGameObject())
        {
            return(true);
        }
        return(false);
    }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        Ping();
        pingStartTime = Time.time;
        loadingImage.SetActive(false);
        loadingText.SetActive(false);
        system = UnityEngine.EventSystems.EventSystem.current;
        incorrectLoginText.text = "";

        SQLHandler.MakeConnection();
        //GetPHPRequest("ayanmitra", "$2y$10$qGDDKK2AVplLeX5Iixy90.ZVpC186MLw3mq7gO8PteaULnUZSHYnG");
    }
Пример #9
0
        public static UnityEngine.EventSystems.EventSystem CreateEventSystem()
        {
            GameObject eventSystemObject = new GameObject();

            eventSystemObject.name = "EventSystem";
            UnityEngine.EventSystems.EventSystem _eventSystem = eventSystemObject.AddComponent <UnityEngine.EventSystems.EventSystem>();
            eventSystemObject.AddComponent <StandaloneInputModule>();
                        #if !UNITY_5_3 && !UNITY_5_4
            eventSystemObject.AddComponent <TouchInputModule>();
                        #endif
            return(_eventSystem);
        }
Пример #10
0
		private void _init ()
		{
			GameObject k = new GameObject ("UI Root");
			this._canvas = k.AddComponent<Canvas> ();
			this._root = k.GetComponent<RectTransform> ();
			k.AddComponent<CanvasScaler> ();
			k.AddComponent<GraphicRaycaster> ();
			
			GameObject events = new GameObject ("UI Events");
			this._events = events.AddComponent<EventSystem> ();
			events.AddComponent<StandaloneInputModule> ();
			events.AddComponent<TouchInputModule> ();
		}
    // Use this for initialization
    void Start()
    {
        myEventSystem = GameObject.Find("EventSystem").GetComponent<EventSystem>();

        foreach(Transform child in transform)
        {
            if (child.tag == "Particle")
            {
                myParticles = child.GetComponent<ParticleSystem>();
                myParticles.gameObject.SetActive(true);
                myParticles.emissionRate = 0;
            }
        }
    }
Пример #12
0
        /// <summary>This will return all the RaycastResults under the specified screen point using the specified layerMask.
        /// NOTE: The first result (0) will be the top UI element that was first hit.</summary>
        public static List <RaycastResult> RaycastGui(Vector2 screenPosition, LayerMask layerMask)
        {
            tempRaycastResults.Clear();

            var currentEventSystem = UnityEngine.EventSystems.EventSystem.current;

            if (currentEventSystem != null)
            {
                // Create point event data for this event system?
                if (currentEventSystem != tempEventSystem)
                {
                    tempEventSystem = currentEventSystem;

                    if (tempPointerEventData == null)
                    {
                        tempPointerEventData = new PointerEventData(tempEventSystem);
                    }
                    else
                    {
                        tempPointerEventData.Reset();
                    }
                }

                // Raycast event system at the specified point
                tempPointerEventData.position = screenPosition;

                currentEventSystem.RaycastAll(tempPointerEventData, tempRaycastResults);

                // Loop through all results and remove any that don't match the layer mask
                if (tempRaycastResults.Count > 0)
                {
                    for (var i = tempRaycastResults.Count - 1; i >= 0; i--)
                    {
                        var raycastResult = tempRaycastResults[i];
                        var raycastLayer  = 1 << raycastResult.gameObject.layer;

                        if ((raycastLayer & layerMask) == 0)
                        {
                            tempRaycastResults.RemoveAt(i);
                        }
                    }
                }
            }
            else
            {
                Debug.LogError("Failed to RaycastGui because your scene doesn't have an event system! To add one, go to: GameObject/UI/EventSystem");
            }

            return(tempRaycastResults);
        }
Пример #13
0
    /// <summary>
    /// post方式网络请求
    /// </summary>
    /// <param name="url"></param>
    /// <param name="fields"></param>
    /// <param name="onSuccess"></param>
    /// <param name="onFailed"></param>
    public static void PostHttp(string url, string fields, System.Action <string> onSuccess, System.Action <string> onFailed)
    {
        Dictionary <string, string> dict = new Dictionary <string, string>();

        if (!string.IsNullOrEmpty(fields))
        {
            string[] str = fields.Split('&');
            for (int i = 0; i + 1 < str.Length; i += 2)
            {
                dict[str[i]] = str[i + 1];
            }
        }
        UnityEngine.EventSystems.EventSystem es = UnityEngine.EventSystems.EventSystem.current;
        es.StartCoroutine(HttpPost(url, dict, onSuccess, onFailed));
    }
Пример #14
0
 public PointerEventData(EventSystem eventSystem) : base(eventSystem)
 {
     this.hovered = new List<GameObject>();
     this.eligibleForClick = false;
     this.pointerId = -1;
     this.position = Vector2.zero;
     this.delta = Vector2.zero;
     this.pressPosition = Vector2.zero;
     this.clickTime = 0f;
     this.clickCount = 0;
     this.scrollDelta = Vector2.zero;
     this.useDragThreshold = true;
     this.dragging = false;
     this.button = InputButton.Left;
 }
Пример #15
0
    private static bool WithinInputField()
    {
        UnityEngine.EventSystems.EventSystem current = UnityEngine.EventSystems.EventSystem.current;
        if ((UnityEngine.Object)current == (UnityEngine.Object)null)
        {
            return(false);
        }
        bool result = false;

        if ((UnityEngine.Object)current.currentSelectedGameObject != (UnityEngine.Object)null && ((UnityEngine.Object)current.currentSelectedGameObject.GetComponent <TMP_InputField>() != (UnityEngine.Object)null || (UnityEngine.Object)current.currentSelectedGameObject.GetComponent <InputField>() != (UnityEngine.Object)null))
        {
            result = true;
        }
        return(result);
    }
Пример #16
0
        public PointerEventData(EventSystem eventSystem) : base(eventSystem)
        {
            eligibleForClick = false;

            pointerId = -1;
            position = Vector2.zero; // Current position of the mouse or touch event
            delta = Vector2.zero; // Delta since last update
            pressPosition = Vector2.zero; // Delta since the event started being tracked
            clickTime = 0.0f; // The last time a click event was sent out (used for double-clicks)
            clickCount = 0; // Number of clicks in a row. 2 for a double-click for example.

            scrollDelta = Vector2.zero;
            useDragThreshold = true;
            dragging = false;
            button = InputButton.Left;
        }
Пример #17
0
 public void SetEventSystemEnabled(bool state)
 {
     if ((Object)evSys == (Object)null)
     {
         evSys = UnityEngine.EventSystems.EventSystem.current;
         if ((Object)evSys == (Object)null)
         {
             Debug.LogWarning("Cannot enable/disable null UI event system");
             return;
         }
     }
     if (evSys.enabled != state)
     {
         evSys.enabled = state;
     }
 }
Пример #18
0
    // Use this for initialization
    void Start()
    {
        defaultLookAt   = Camera.main.transform.forward;
        defaultPosition = Camera.main.transform.position;
        defaultRotation = Camera.main.transform.rotation;

        myEventSystem  = GameObject.Find("EventSystem").GetComponent <EventSystem> ();
        myUIcontroller = GameObject.Find("ManiSceneUIManager").GetComponent <MainGameUIScript> ();

        text1 = GameObject.Find("buildingTB1").GetComponent <Text> ();
        text2 = GameObject.Find("buildingTB2").GetComponent <Text> ();
        text3 = GameObject.Find("buildingTB3").GetComponent <Text> ();
        text4 = GameObject.Find("buildingTB4").GetComponent <Text> ();
        text5 = GameObject.Find("buildingTB5").GetComponent <Text> ();
        text6 = GameObject.Find("buildingTB6").GetComponent <Text> ();
    }
Пример #19
0
    public override void Initalize()
    {
        base.Initalize();
        if (gameObject == null)
        {
            gameObject          = ResourceLoad.Load(GameUIRootName);
            gameObject.name     = "UGUIRoot";
            tranform            = gameObject.transform;
            eventSystem         = Utility.GameUtility.FindDeepChild <EventSystem>(gameObject, "EventSystem");
            eventSystem.enabled = true;
            ResetNode(tranform);
            InitalizeCanvas();
            GameObject.DontDestroyOnLoad(gameObject);
        }

        InitalizePreLoadUI();
    }
Пример #20
0
    public virtual bool ShowHoverUI()
    {
        bool result = false;

        UnityEngine.EventSystems.EventSystem current = UnityEngine.EventSystems.EventSystem.current;
        if ((UnityEngine.Object)current != (UnityEngine.Object)null)
        {
            Vector3          mousePos         = KInputManager.GetMousePos();
            float            x                = mousePos.x;
            Vector3          mousePos2        = KInputManager.GetMousePos();
            Vector3          v                = new Vector3(x, mousePos2.y, 0f);
            PointerEventData pointerEventData = new PointerEventData(current);
            pointerEventData.position = v;
            current.RaycastAll(pointerEventData, castResults);
            result = (castResults.Count == 0);
        }
        return(result);
    }
Пример #21
0
        public void Start()
        {
            mFirstFrame    = true;
            mUIEventSystem = GetComponent <UnityEngine.EventSystems.EventSystem>();

            if (InputWrapper.AnyJoysticksConnected())
            {
                joystickWasConnected = true;
                mUIEventSystem.SetSelectedGameObject(mUIEventSystem.firstSelectedGameObject);
            }
            else
            {
                joystickWasConnected = false;
                mUIEventSystem.SetSelectedGameObject(null);
            }

            mInputModule = GetComponent <UnityEngine.EventSystems.StandaloneInputModule>();
            mInputModule.horizontalAxis = InputWrapper.LeftXInputName;
            mInputModule.verticalAxis   = InputWrapper.LeftYInputName;
        }
Пример #22
0
        private bool WasAButton()
        {
            UnityEngine.EventSystems.EventSystem ct
                = UnityEngine.EventSystems.EventSystem.current;

            if (!ct.IsPointerOverGameObject())
            {
                return(false);
            }
            if (!ct.currentSelectedGameObject)
            {
                return(false);
            }
            if (ct.currentSelectedGameObject.GetComponent <Button>() == null)
            {
                return(false);
            }

            return(true);
        }
Пример #23
0
        public void Awake()
        {
            this.camera = FindObjectOfType<CameraController>();
            this.eventSystem = FindObjectOfType<EventSystem>();
            this.font = (font == null) ? Resources.GetBuiltinResource<Font>("Arial.ttf") : font;
            this.labels = GetComponentsInChildren<Text>();
            this.menus = GetComponentsInChildren<Canvas>().Select(c => c.gameObject).ToArray();

            GetComponentsInChildren<Selectable>().ToList().ForEach(s => s.colors = colors);

            foreach (Text label in labels)
            {
                label.font = font;
                label.text = label.text.Localize();
            }

            if (eventSystem == null)
            {
                eventSystem = new GameObject("Event System", typeof(EventSystem)).GetComponent<EventSystem>();
            }
        }
Пример #24
0
        /**
         * Creates a generic EventSystem object for Unity UI-based Menus to use.
         */
        public static UnityEngine.EventSystems.EventSystem CreateEventSystem()
        {
            GameObject eventSystemObject = new GameObject();

            eventSystemObject.name = "EventSystem";
            UnityEngine.EventSystems.EventSystem _eventSystem = eventSystemObject.AddComponent <UnityEngine.EventSystems.EventSystem>();

            if (KickStarter.settingsManager.inputMethod == InputMethod.TouchScreen)
            {
                eventSystemObject.AddComponent <StandaloneInputModule>();
            }
            else
            {
                eventSystemObject.AddComponent <OptionalMouseInputModule>();
            }
                        #if UNITY_5_3 || UNITY_5_4 || UNITY_5_3_OR_NEWER
                        #else
            eventSystemObject.AddComponent <TouchInputModule>();
                        #endif
            return(_eventSystem);
        }
        public static VRTK_EventSystemVRInput SetEventSystem(EventSystem eventSystem)
        {
            if (!eventSystem)
            {
                Debug.LogError("A VRTK_UIPointer requires an EventSystem");
            }

            //disable existing standalone input module
            var standaloneInputModule = eventSystem.gameObject.GetComponent<StandaloneInputModule>();
            if (standaloneInputModule.enabled)
            {
                standaloneInputModule.enabled = false;
            }

            //if it doesn't already exist, add the custom event system
            var eventSystemInput = eventSystem.GetComponent<VRTK_EventSystemVRInput>();
            if (!eventSystemInput)
            {
                eventSystemInput = eventSystem.gameObject.AddComponent<VRTK_EventSystemVRInput>();
                eventSystemInput.Initialise();
            }

            return eventSystemInput;
        }
        public void Awake()
        {
            this.camera = Camera.main.gameObject.GetComponent<CameraController>();
            this.chapters = GetComponentsInChildren<Canvas>().Select(c => c.gameObject).ToArray();
            this.eventSystem = FindObjectOfType<EventSystem>();
            this.menu = FindObjectOfType<MenuController>();
            this.mounts = chapters.Select(c => c.transform.FindChild("Mounting Point").gameObject).ToArray();

            // Enable Menu, Intro & Tower 1
            PlayerPrefs.SetInt("bIsLevelAvailable0", 1);
            PlayerPrefs.SetInt("bIsLevelAvailable1", 1);
            PlayerPrefs.SetInt("bIsLevelAvailable2", 1);
            if (Debug.isDebugBuild) { // Enable all towers when in editor
                PlayerPrefs.SetInt("bIsLevelAvailable3", 1);
                PlayerPrefs.SetInt("bIsLevelAvailable4", 1);
                PlayerPrefs.SetInt("bIsLevelAvailable5", 1);
                PlayerPrefs.SetInt("bIsLevelAvailable6", 1);
            }

            int levelIndex = 1;

            foreach (Button button in GetComponentsInChildren<Button>()) {
                // Assign functions to each button in the menu
                if (PlayerPrefs.GetInt("bIsLevelAvailable" + levelIndex, 0) > 0) {
                    button.interactable = true;
                } else {
                    button.interactable = false;
                }

                if (levelIndex == 1) {
                    levelIndex++;
                }

                levelIndex++;
            }
        }
Пример #27
0
		private static void disableUI(bool pause) {
#if UNITY_4_6 || UNITY_5
			// EventSystem is Unity4.6 and later
			if( pause && EventSystem.current )
			{
				kEventSystem = EventSystem.current;
				kEventSystem.enabled = false;
			}
			else if( !pause && kEventSystem ) {
				kEventSystem.enabled = true;
				EventSystem.current = kEventSystem;
			}
#endif
		}
Пример #28
0
 protected override void OnSpawn()
 {
     base.OnSpawn();
     evSys = UnityEngine.EventSystems.EventSystem.current;
 }
Пример #29
0
 private MovementEventData(EventSystem eventSystem, RelativeDirection relativeDirection)
     : base(eventSystem)
 {
     this.relativeDirection = relativeDirection;
 }
Пример #30
0
 static public int get_sendNavigationEvents(IntPtr l)
 {
     UnityEngine.EventSystems.EventSystem o = (UnityEngine.EventSystems.EventSystem)checkSelf(l);
     pushValue(l, o.sendNavigationEvents);
     return(1);
 }
 // Start is called before the first frame update
 void Awake()
 {
     eventSystem = GameObject.FindObjectOfType <UnityEngine.EventSystems.EventSystem>();
     selectable  = GetComponent <UnityEngine.UI.Selectable>();
 }
Пример #32
0
 static public int get_alreadySelecting(IntPtr l)
 {
     UnityEngine.EventSystems.EventSystem o = (UnityEngine.EventSystems.EventSystem)checkSelf(l);
     pushValue(l, o.alreadySelecting);
     return(1);
 }
Пример #33
0
		// Use this for initialization
		void Start () {
			eventSystem = GetComponentInParent<EventSystem> ();
		}
Пример #34
0
    private UnityEngine.Vector2 ProjectPointer(float x, float y)
    {
        if (_camera != null)
        {
            return(new UnityEngine.Vector2(x, UnityEngine.Screen.height - y));
        }
        else if (_texture != null)
        {
            // Project using texture coordinates

            // First try with Unity GUI RawImage objects
            UnityEngine.EventSystems.EventSystem eventSystem = UnityEngine.EventSystems.EventSystem.current;

            if (eventSystem != null && eventSystem.IsPointerOverGameObject())
            {
                UnityEngine.Vector2 pos = new UnityEngine.Vector2(x, y);

                if (_pointerData == null)
                {
                    _pointerData = new UnityEngine.EventSystems.PointerEventData(eventSystem)
                    {
                        pointerId = 0,
                        position  = pos
                    };
                }
                else
                {
                    _pointerData.Reset();
                }

                _pointerData.delta    = pos - _pointerData.position;
                _pointerData.position = pos;

                UnityEngine.RectTransform rect = GetComponent <UnityEngine.RectTransform>();

                if (rect != null &&
                    UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(
                        rect, _pointerData.position, _pointerData.pressEventCamera, out pos))
                {
                    UnityEngine.Vector2 pivot = new UnityEngine.Vector2(
                        rect.pivot.x * rect.rect.width,
                        rect.pivot.y * rect.rect.height);

                    float texCoordX = (pos.x + pivot.x) / rect.rect.width;
                    float texCoordY = (pos.y + pivot.y) / rect.rect.height;

                    float localX = _texture.width * texCoordX;
                    float localY = _texture.height * (1.0f - texCoordY);
                    return(new UnityEngine.Vector2(localX, localY));
                }
            }

            // NOTE: A MeshCollider must be attached to the target to obtain valid
            // texture coordinates, otherwise Hit Testing won't work

            UnityEngine.Ray ray = UnityEngine.Camera.main.ScreenPointToRay(new UnityEngine.Vector3(x, y, 0));

            UnityEngine.RaycastHit hit;
            if (UnityEngine.Physics.Raycast(ray, out hit))
            {
                if (hit.collider.gameObject == gameObject)
                {
                    float localX = _texture.width * hit.textureCoord.x;
                    float localY = _texture.height * (1.0f - hit.textureCoord.y);
                    return(new UnityEngine.Vector2(localX, localY));
                }
            }

            return(new UnityEngine.Vector2(-1, -1));
        }

        return(Vector2.zero);
    }
Пример #35
0
        void Awake()
        {
            InputController.SetForKeyboard();
            InputController.SetGravity(5);
            InputController.SetSensitivity(5);

            InputController.SetGamePads();
            InputController.SetAcceptGravityToAnalogPad(true);

            GameStatus.Initialilze();
            rtfButtonPanel = GameObject.Find("/Canvas/ButtonPanel").GetComponent<RectTransform>();
            rtfButtons = rtfButtonPanel.FindChild("Buttons").GetComponent<RectTransform>();
            rtfExpression = rtfButtonPanel.FindChild("ButtonExpression").GetComponent<RectTransform>();
            txtExpression = rtfExpression.FindChild("Text").GetComponent<Text>();
            rtfStatus = GameObject.Find("/Canvas/StatusPanel/Statuses").GetComponent<RectTransform>();
            expressionAnimator = rtfExpression.GetComponent<Animator>();
            eventSystem = GameObject.Find("/EventSystem").GetComponent<EventSystem>();

            buttonList = new List<Button>();
            buttonList.Add(rtfButtons.FindChild("BattleButton").GetComponent<Button>());
            buttonList.Add(rtfButtons.FindChild("PartsButton").GetComponent<Button>());
            buttonList.Add(rtfButtons.FindChild("AIButton").GetComponent<Button>());
            buttonList.Add(rtfButtons.FindChild("SettingButton").GetComponent<Button>());
            buttonList.Add(rtfButtons.FindChild("RecordButton").GetComponent<Button>());
            buttonList.Add(rtfButtons.FindChild("ExitButton").GetComponent<Button>());

            int x = 1;
            int y = x++ + ++x;
            Debug.Log(y);
        }
Пример #36
0
 private AttackEventData(EventSystem eventSystem)
     : base(eventSystem)
 {
 }
Пример #37
0
        protected override void Start()
        {
            base.Start();

            _eventSystem = GetComponent<EventSystem>();
        }
Пример #38
0
 public void Start()
 {
     eventSystem = UnityEngine.EventSystems.EventSystem.current;
 }
 public InputEventData(EventSystem eventSystem)
     : base(eventSystem)
 {
 }
Пример #40
0
 void Start()
 {
     _eventSystem = FindObjectOfType <UnityEngine.EventSystems.EventSystem>();
 }
Пример #41
0
 static public int get_pixelDragThreshold(IntPtr l)
 {
     UnityEngine.EventSystems.EventSystem o = (UnityEngine.EventSystems.EventSystem)checkSelf(l);
     pushValue(l, o.pixelDragThreshold);
     return(1);
 }
Пример #42
0
 static public int get_currentInputModule(IntPtr l)
 {
     UnityEngine.EventSystems.EventSystem o = (UnityEngine.EventSystems.EventSystem)checkSelf(l);
     pushValue(l, o.currentInputModule);
     return(1);
 }
Пример #43
0
 static public int get_firstSelectedGameObject(IntPtr l)
 {
     UnityEngine.EventSystems.EventSystem o = (UnityEngine.EventSystems.EventSystem)checkSelf(l);
     pushValue(l, o.firstSelectedGameObject);
     return(1);
 }
Пример #44
0
 private void Start()
 {
     current     = UnityEngine.EventSystems.EventSystem.current;
     pointerData = new PointerEventData(current);
 }
Пример #45
0
 /// <summary>
 /// 
 /// <para>
 /// Construct a BaseEventData tied to the passed EventSystem.
 /// </para>
 /// 
 /// </summary>
 /// <param name="eventSystem"/>
 public BaseEventData(EventSystem eventSystem)
 {
   this.m_EventSystem = eventSystem;
 }
Пример #46
0
 /// <summary>
 /// <para>See MonoBehaviour.OnEnable.</para>
 /// </summary>
 protected override void OnEnable()
 {
     base.OnEnable();
     this.m_EventSystem = base.GetComponent<EventSystem>();
     this.m_EventSystem.UpdateModules();
 }
 void Start()
 {
     _system = EventSystem.current;
 }
Пример #48
0
 public AxisEventData(EventSystem eventSystem) : base(eventSystem)
 {
     this.moveVector = Vector2.zero;
     this.moveDir = MoveDirection.None;
 }
Пример #49
0
 private TakeDamageEventData(EventSystem eventSystem, int damage)
     : base(eventSystem)
 {
     this.damage = damage;
 }
Пример #50
0
 void Awake()
 {
     AddObserver(GameManager.Instance);
     Notify(gameObject, GameEvent.Menu);
     m_EventSystem = GameObject.FindObjectOfType<UnityEngine.EventSystems.EventSystem>();
 }
Пример #51
0
 void Awake()
 {
     m_MainMenuCanvas = GameObject.Find("MainMenu");
     m_EventSystem = FindObjectOfType<UnityEngine.EventSystems.EventSystem>();
 }
Пример #52
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            drawInEditor = EditorGUILayout.Toggle("Test in Game Window?", drawInEditor);
            drawOutlines = EditorGUILayout.Toggle("Draw outlines?", drawOutlines);
            if (drawOutlines && Application.platform == RuntimePlatform.WindowsEditor)
            {
                doWindowsPreviewFix = EditorGUILayout.Toggle("Apply outline offset fix?", doWindowsPreviewFix);
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Pause background texture:", GUILayout.Width(255f));
            pauseTexture = (Texture2D)CustomGUILayout.ObjectField <Texture2D> (pauseTexture, false, GUILayout.Width(70f), GUILayout.Height(30f), "AC.Kickstarter.menuManager.pauseTexture");
            EditorGUILayout.EndHorizontal();
            scaleTextEffects = CustomGUILayout.Toggle("Scale text effects?", scaleTextEffects, "AC.KickStarter.menuManager.scaleTextEffects");
            globalDepth      = CustomGUILayout.IntField("GUI depth:", globalDepth, "AC.KickStarter.menuManager.globalDepth");
            eventSystem      = (UnityEngine.EventSystems.EventSystem)CustomGUILayout.ObjectField <UnityEngine.EventSystems.EventSystem> ("Event system prefab:", eventSystem, false, "AC.KickStarter.menuManager.eventSystem");

            if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.inputMethod == InputMethod.KeyboardOrController)
            {
                EditorGUILayout.Space();
                keyboardControlWhenPaused        = CustomGUILayout.ToggleLeft("Directly-navigate Menus when paused?", keyboardControlWhenPaused, "AC.KickStarter.menuManager.keyboardControlWhenPaused");
                keyboardControlWhenDialogOptions = CustomGUILayout.ToggleLeft("Directly-navigate Menus during Conversations?", keyboardControlWhenDialogOptions, "AC.KickStarter.menuManager.keyboardControlWhenDialogOptions");
            }

            if (drawInEditor && KickStarter.menuPreview == null)
            {
                EditorGUILayout.HelpBox("A GameEngine prefab is required to display menus while editing - please click Organise Room Objects within the Scene Manager.", MessageType.Warning);
            }
            else if (Application.isPlaying)
            {
                EditorGUILayout.HelpBox("Changes made to the menus will not be registed by the game until the game is restarted.", MessageType.Info);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            CreateMenusGUI();

            if (selectedMenu != null)
            {
                EditorGUILayout.Space();

                string menuTitle = selectedMenu.title;
                if (menuTitle == "")
                {
                    menuTitle = "(Untitled)";
                }

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                EditorGUILayout.LabelField("Menu " + selectedMenu.id + ": '" + menuTitle + "' properties", CustomStyles.subHeader);
                EditorGUILayout.Space();
                selectedMenu.ShowGUI();
                EditorGUILayout.EndVertical();

                EditorGUILayout.Space();

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                EditorGUILayout.LabelField("Menu " + selectedMenu.id + ": '" + menuTitle + "' elements", CustomStyles.subHeader);
                EditorGUILayout.Space();
                CreateElementsGUI(selectedMenu);
                EditorGUILayout.EndVertical();

                if (selectedMenuElement != null)
                {
                    EditorGUILayout.Space();

                    string elementName = selectedMenuElement.title;
                    if (elementName == "")
                    {
                        elementName = "(Untitled)";
                    }

                    string elementType = "";
                    foreach (string _elementType in elementTypes)
                    {
                        if (selectedMenuElement.GetType().ToString().Contains(_elementType))
                        {
                            elementType = _elementType;
                            break;
                        }
                    }

                    EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                    EditorGUILayout.LabelField(elementType + " " + selectedMenuElement.ID + ": '" + elementName + "' properties", CustomStyles.subHeader);
                    oldVisibility = selectedMenuElement.isVisible;
                    selectedMenuElement.ShowGUIStart(selectedMenu);
                    if (selectedMenuElement.isVisible != oldVisibility)
                    {
                        if (!Application.isPlaying)
                        {
                            selectedMenu.Recalculate();
                        }
                    }
                }
            }

            if (GUI.changed)
            {
                if (!Application.isPlaying)
                {
                    SaveAllMenus();
                }
                EditorUtility.SetDirty(this);
            }
        }
Пример #53
0
    private bool AlternateUITest(Vector3 MouseRaw)
    {
        GraphicRaycaster gr = GameObject.FindGameObjectWithTag("Canvas").GetComponent <GraphicRaycaster>();

        UnityEngine.EventSystems.EventSystem es = GameManager.Instance.transform.GetComponentInChildren <UnityEngine.EventSystems.EventSystem>();

        if (es == null)
        {
            Debug.LogError("NO EventSys");
        }

        //Set up the new Pointer Event
        PointerEventData m_PointerEventData = new PointerEventData(es);

        //Set the Pointer Event Position to that of the mouse position
        m_PointerEventData.position = MouseRaw;

        //Create a list of Raycast Results
        List <RaycastResult> results = new List <RaycastResult>();

        //RayCast it
        if (gr)
        {
            gr.Raycast(m_PointerEventData, results);
        }
        else
        {
            Debug.LogError("NO GraphicRaycaster");
        }

        //For every result returned, output the name of the GameObject on the Canvas hit by the Ray
        foreach (RaycastResult result in results)
        {
            if (_printStatements)
            {
                Debug.LogError("GraphicCaster Hit " + result.gameObject.name);
            }
            if (result.gameObject.GetComponent <Button>())
            {
                if (_printStatements)
                {
                    Debug.Log("Found a Button Setting clicks to false" + result.gameObject);
                }

                if (result.gameObject.GetComponent <UIDismissCan>())
                {
                    _DismissOveride = true;
                    _DismissCan     = result.gameObject.GetComponent <UIDismissCan>();
                    return(false);
                }
                else if (result.gameObject.GetComponent <UIDraggableButton>())
                {
                    if (!result.gameObject.GetComponent <UIDraggableButton>().isSelected())
                    {
                        result.gameObject.GetComponent <UIDraggableButton>().imClicked();
                        return(false);
                    }
                }
                else if (result.gameObject.GetComponent <UIAssignmentVFX>())
                {
                    result.gameObject.GetComponent <UIAssignmentVFX>().imClicked();
                    return(false);
                }
                else if (result.gameObject.GetComponent <UIStaminaButton>())
                {
                    result.gameObject.GetComponent <UIStaminaButton>().imClicked();
                    return(false);
                }
                else if (result.gameObject.GetComponent <UIAssignmentMovement>())
                {
                    result.gameObject.GetComponent <UIAssignmentMovement>().imClicked();

                    return(false);
                }
            }
            else if (result.gameObject.GetComponent <UIStaminaHitBox>())
            {
                result.gameObject.GetComponent <UIStaminaHitBox>().imClicked();
            }
        }
        if (results.Count <= 0 && (_printStatements))
        {
            Debug.LogWarning("We tried to GraphicRaycast UI and failed @" + m_PointerEventData.position);
        }



        m_PointerEventData.position = (MouseRaw);
        results.Clear();
        UnityEngine.EventSystems.EventSystem.current.RaycastAll(m_PointerEventData, results);
        if (results.Count > 0)
        {
            foreach (RaycastResult result in results)
            {
                if (_printStatements)
                {
                    Debug.LogError("Alternate Hit " + result.gameObject.name);
                }
                if (result.gameObject.GetComponent <Button>())
                {
                    if (_printStatements)
                    {
                        Debug.Log("Found a Button Setting clicks to false");
                    }

                    //Might need to check certain buttons scripts to set assignmentDummy=true;


                    return(false);
                }
                else if (result.gameObject.GetComponent <bWorkerScript>())
                {
                    // Debug.Log("Found B Worker Script");
                    result.gameObject.GetComponent <bWorkerScript>().imClicked();
                }
            }
        }
        else if (_printStatements)
        {
            Debug.LogWarning("We tried to ALLRaycast UI and failed @" + m_PointerEventData.position);
        }

        return(true);
    }
Пример #54
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            if (icon == null)
            {
                icon = (Texture2D) AssetDatabase.LoadAssetAtPath ("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof (Texture2D));
            }

            EditorGUILayout.BeginVertical ("Button");
                drawInEditor = EditorGUILayout.Toggle ("Test in Game Window?", drawInEditor);
                drawOutlines = EditorGUILayout.Toggle ("Draw outlines?", drawOutlines);
                EditorGUILayout.BeginHorizontal ();
                    EditorGUILayout.LabelField ("Pause background texture:", GUILayout.Width (255f));
                    pauseTexture = (Texture2D) EditorGUILayout.ObjectField (pauseTexture, typeof (Texture2D), false, GUILayout.Width (70f), GUILayout.Height (30f));
                EditorGUILayout.EndHorizontal ();
                scaleTextEffects = EditorGUILayout.Toggle ("Scale text effects?", scaleTextEffects);
                globalDepth = EditorGUILayout.IntField ("GUI depth:", globalDepth);
                eventSystem = (UnityEngine.EventSystems.EventSystem) EditorGUILayout.ObjectField ("Event system prefab:", eventSystem, typeof (UnityEngine.EventSystems.EventSystem), false);

                if (drawInEditor && KickStarter.menuPreview == null)
                {
                    EditorGUILayout.HelpBox ("A GameEngine prefab is required to display menus while editing - please click Organise Room Objects within the Scene Manager.", MessageType.Warning);
                }
                else if (Application.isPlaying)
                {
                    EditorGUILayout.HelpBox ("Changes made to the menus will not be registed by the game until the game is restarted.", MessageType.Info);
                }
            EditorGUILayout.EndVertical ();

            EditorGUILayout.Space ();

            EditorGUILayout.LabelField ("Menus", EditorStyles.boldLabel);
            CreateMenusGUI ();

            if (selectedMenu != null)
            {
                EditorGUILayout.Space ();

                string menuTitle = selectedMenu.title;
                if (menuTitle == "")
                {
                    menuTitle = "(Untitled)";
                }

                EditorGUILayout.LabelField ("Menu " + selectedMenu.id + ": '" + menuTitle + "' properties", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical ("Button");
                    selectedMenu.ShowGUI ();
                EditorGUILayout.EndVertical ();

                EditorGUILayout.Space ();

                EditorGUILayout.LabelField ("Menu " + selectedMenu.id + ": '" + menuTitle + "' elements", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical ("Button");
                    CreateElementsGUI (selectedMenu);
                EditorGUILayout.EndVertical ();

                if (selectedMenuElement != null)
                {
                    EditorGUILayout.Space ();

                    string elementName = selectedMenuElement.title;
                    if (elementName == "")
                    {
                        elementName = "(Untitled)";
                    }

                    string elementType = "";
                    foreach (string _elementType in elementTypes)
                    {
                        if (selectedMenuElement.GetType ().ToString ().Contains (_elementType))
                        {
                            elementType = _elementType;
                            break;
                        }
                    }

                    EditorGUILayout.LabelField (elementType + " " + selectedMenuElement.ID + ": '" + elementName + "' properties", EditorStyles.boldLabel);
                    oldVisibility = selectedMenuElement.isVisible;
                    selectedMenuElement.ShowGUIStart (selectedMenu.menuSource);
                    if (selectedMenuElement.isVisible != oldVisibility)
                    {
                        if (!Application.isPlaying)
                        {
                            selectedMenu.Recalculate ();
                        }
                    }
                }
            }

            if (GUI.changed)
            {
                if (!Application.isPlaying)
                {
                    SaveAllMenus ();
                }
                EditorUtility.SetDirty (this);
            }
        }
Пример #55
0
        public void ShowGUI()
        {
            if (icon == null)
            {
                icon = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof(Texture2D));
            }

            EditorGUILayout.BeginVertical("Button");
            drawInEditor = EditorGUILayout.Toggle("Test in Game Window?", drawInEditor);
            drawOutlines = EditorGUILayout.Toggle("Draw outlines?", drawOutlines);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Pause background texture:", GUILayout.Width(255f));
            pauseTexture = (Texture2D)EditorGUILayout.ObjectField(pauseTexture, typeof(Texture2D), false, GUILayout.Width(70f), GUILayout.Height(30f));
            EditorGUILayout.EndHorizontal();
            scaleTextEffects = EditorGUILayout.Toggle("Scale text effects?", scaleTextEffects);
            globalDepth      = EditorGUILayout.IntField("GUI depth:", globalDepth);
            eventSystem      = (UnityEngine.EventSystems.EventSystem)EditorGUILayout.ObjectField("Event system prefab:", eventSystem, typeof(UnityEngine.EventSystems.EventSystem), false);

            if (drawInEditor && KickStarter.menuPreview == null)
            {
                EditorGUILayout.HelpBox("A GameEngine prefab is required to display menus while editing - please click Organise Room Objects within the Scene Manager.", MessageType.Warning);
            }
            else if (Application.isPlaying)
            {
                EditorGUILayout.HelpBox("Changes made to the menus will not be registed by the game until the game is restarted.", MessageType.Info);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Menus", EditorStyles.boldLabel);
            CreateMenusGUI();

            if (selectedMenu != null)
            {
                EditorGUILayout.Space();

                string menuTitle = selectedMenu.title;
                if (menuTitle == "")
                {
                    menuTitle = "(Untitled)";
                }

                EditorGUILayout.LabelField("Menu " + selectedMenu.id + ": '" + menuTitle + "' properties", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical("Button");
                selectedMenu.ShowGUI();
                EditorGUILayout.EndVertical();

                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Menu " + selectedMenu.id + ": '" + menuTitle + "' elements", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical("Button");
                CreateElementsGUI(selectedMenu);
                EditorGUILayout.EndVertical();

                if (selectedMenuElement != null)
                {
                    EditorGUILayout.Space();

                    string elementName = selectedMenuElement.title;
                    if (elementName == "")
                    {
                        elementName = "(Untitled)";
                    }

                    string elementType = "";
                    foreach (string _elementType in elementTypes)
                    {
                        if (selectedMenuElement.GetType().ToString().Contains(_elementType))
                        {
                            elementType = _elementType;
                            break;
                        }
                    }

                    EditorGUILayout.LabelField(elementType + " " + selectedMenuElement.ID + ": '" + elementName + "' properties", EditorStyles.boldLabel);
                    oldVisibility = selectedMenuElement.isVisible;
                    selectedMenuElement.ShowGUIStart(selectedMenu.menuSource);
                    if (selectedMenuElement.isVisible != oldVisibility)
                    {
                        if (!Application.isPlaying)
                        {
                            selectedMenu.Recalculate();
                        }
                    }
                }
            }

            if (GUI.changed)
            {
                if (!Application.isPlaying)
                {
                    SaveAllMenus();
                }
                EditorUtility.SetDirty(this);
            }
        }
Пример #56
0
        private void CreateEventSystem()
        {
            if (GameObject.FindObjectOfType <UnityEngine.EventSystems.EventSystem>() == null)
            {
                UnityEngine.EventSystems.EventSystem _eventSystem = null;

                if (KickStarter.menuManager.eventSystem != null)
                {
                    _eventSystem = (UnityEngine.EventSystems.EventSystem) Instantiate (KickStarter.menuManager.eventSystem);
                    _eventSystem.gameObject.name = KickStarter.menuManager.eventSystem.name;
                }
                else if (AreAnyMenusUI ())
                {
                    GameObject eventSystemObject = new GameObject ();
                    eventSystemObject.name = "EventSystem";
                    _eventSystem = eventSystemObject.AddComponent <UnityEngine.EventSystems.EventSystem>();
                    eventSystemObject.AddComponent <StandaloneInputModule>();
                    eventSystemObject.AddComponent <TouchInputModule>();
                }

                if (_eventSystem != null)
                {
                    if (GameObject.Find ("_UI"))
                    {
                        _eventSystem.transform.SetParent (GameObject.Find ("_UI").transform);
                    }
                    eventSystem = _eventSystem;
                }
            }
        }
Пример #57
0
 void Awake()
 {
     AddObserver(GameManager.Instance);
     m_MainMenuCanvas = GameObject.Find("MainMenu");
     m_EventSystem = FindObjectOfType<UnityEngine.EventSystems.EventSystem>();
 }
Пример #58
-1
	// Update is called once per frame
	void Update () {
		current = UnityEngine.EventSystems.EventSystem.current;
		selected = current.currentSelectedGameObject;
		all = FindObjectsOfType<UnityEngine.EventSystems.EventSystem> ();
		MM = GameObject.Find ("EventSystemMM");
		OP = GameObject.Find ("EventSystemOP");
		LB = GameObject.Find ("EventSystemLB");
	}
Пример #59
-1
 void Awake()
 {
     m_EventSystem = FindObjectOfType<UnityEngine.EventSystems.EventSystem>();
     m_InputMenuCanvas = GameObject.Find("InputMenu");
     if(GameObject.Find("VideoMenu") != null)
     m_VideoMenuCanvas = GameObject.Find("VideoMenu");
     if (GameObject.Find("MainMenu") != null)
     m_MainMenuCanvas = GameObject.Find("MainMenu");
     if (GameObject.Find("PauseMenu") != null)
     m_PauseMenuCanvas = GameObject.Find("PauseMenu");
 }
Пример #60
-1
    void Awake()
    {
        m_OptionsMenuCanvas = GameObject.Find("OptionsMenu");
        m_EventSystem = FindObjectOfType<UnityEngine.EventSystems.EventSystem>();

        m_InputTypeText = GameObject.Find("KeyboardOrXbox").GetComponentInChildren<Text>();
        m_InteractText = GameObject.Find("Interact").GetComponentInChildren<Text>();
        m_JumpText = GameObject.Find("Jump").GetComponentInChildren<Text>();
        m_SprintText = GameObject.Find("Sprint").GetComponentInChildren<Text>();
        m_AttackText = GameObject.Find("Attack").GetComponentInChildren<Text>();
        m_PauseText = GameObject.Find("Pause").GetComponentInChildren<Text>();
        m_HelpText = GameObject.Find("Help").GetComponentInChildren<Text>();
    }