C# Класс MouseWorldPosition, astrochimps

Script to filter all the mouse actions, including moving and clicking the buttons. Right now, we use left click to 'select' units and buildings, and right click to issue 'action' commands
Наследование: MonoBehaviour
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
cursorAttack UnityEngine.Texture2D
cursorBuild UnityEngine.Texture2D
cursorCaptureRay UnityEngine.Texture2D
cursorGetInside UnityEngine.Texture2D
cursorGetOut UnityEngine.Texture2D
cursorNormal UnityEngine.Texture2D
cursorObject Transform
cursorRecycleEnable UnityEngine.Texture2D
cursorReprogramEnable UnityEngine.Texture2D
cursorSabotageEnable UnityEngine.Texture2D
cursorWalk UnityEngine.Texture2D
cursorWalkNotOk UnityEngine.Texture2D
gameBarBottom float
gameBarTop float
mouseHitPointNow Vector3
selectedObject Transform
targetPosition Vector3

Открытые методы

Метод Описание
DeselectedObject ( ) : void

Called from an external script, when a unit is deselected

GetSelectedObject ( ) : Transform

Return the transform of the object currently selected, if any

IWantToSelectAPosition ( ) : void

Executed when a script wants to receive a position when a mouse button is clicked

PositionIsAlreadySelected ( ) : bool

Used after IWantToSelectAPosition by another script, so it will know when something is clicked and a position is selected

RemoveCursor ( ) : void

Removes the cursor projector, destroying its object Used when we have deselected a unit

SelectObject ( Transform targetObject ) : void
WhatIsThePositionSelected ( ) : Vector3

Used in conjuction with IWantToSelectAPosition and PositionIsAlreadySelected. If the position is already select, them polls this script to know what is this position

Приватные методы

Метод Описание
Awake ( ) : void
CheckLeftMouseClick ( ) : void

Execute when the player presses the left mouse button Behaviours: select an unit, deselect-it if clicked in the terrain

CheckRightMouseClick ( ) : void

Execute when the player presses the right mouse button Behaviours: when a movable unit is selected, select where it should walk to

DoCheatingStuff ( ) : void

Do some cheats, for development purposes only

GetWhatIClicked ( ) : Transform

When the player presses the mouse button, check whatever is under the mouse cursor through a raycast

MouseOver ( ) : void

Checks the objects under the mouse cursor, showing its info in the info panel Actually, this is the main function of this script: it analyzes the context and set the mouse state and cursor accordingly

OnGUI ( ) : void

For now, the OnGUI only draws the custom mouse cursor

ShowSelectedPositionWithAProjector ( Vector3 position, float timeToShow ) : IEnumerator

When the player select a position to walk to, we show a cursor in the ground for visual aid

Start ( ) : void
Update ( ) : void

Описание методов

DeselectedObject() публичный Метод

Called from an external script, when a unit is deselected
public DeselectedObject ( ) : void
Результат void

GetSelectedObject() публичный Метод

Return the transform of the object currently selected, if any
public GetSelectedObject ( ) : Transform
Результат Transform

IWantToSelectAPosition() публичный Метод

Executed when a script wants to receive a position when a mouse button is clicked
public IWantToSelectAPosition ( ) : void
Результат void

PositionIsAlreadySelected() публичный Метод

Used after IWantToSelectAPosition by another script, so it will know when something is clicked and a position is selected
public PositionIsAlreadySelected ( ) : bool
Результат bool

RemoveCursor() публичный Метод

Removes the cursor projector, destroying its object Used when we have deselected a unit
public RemoveCursor ( ) : void
Результат void

SelectObject() публичный Метод

public SelectObject ( Transform targetObject ) : void
targetObject Transform
Результат void

WhatIsThePositionSelected() публичный Метод

Used in conjuction with IWantToSelectAPosition and PositionIsAlreadySelected. If the position is already select, them polls this script to know what is this position
public WhatIsThePositionSelected ( ) : Vector3
Результат Vector3

Описание свойств

cursorAttack публичное свойство

public Texture2D,UnityEngine cursorAttack
Результат UnityEngine.Texture2D

cursorBuild публичное свойство

public Texture2D,UnityEngine cursorBuild
Результат UnityEngine.Texture2D

cursorCaptureRay публичное свойство

public Texture2D,UnityEngine cursorCaptureRay
Результат UnityEngine.Texture2D

cursorGetInside публичное свойство

public Texture2D,UnityEngine cursorGetInside
Результат UnityEngine.Texture2D

cursorGetOut публичное свойство

public Texture2D,UnityEngine cursorGetOut
Результат UnityEngine.Texture2D

cursorNormal публичное свойство

public Texture2D,UnityEngine cursorNormal
Результат UnityEngine.Texture2D

cursorObject публичное свойство

public Transform cursorObject
Результат Transform

cursorRecycleEnable публичное свойство

public Texture2D,UnityEngine cursorRecycleEnable
Результат UnityEngine.Texture2D

cursorReprogramEnable публичное свойство

public Texture2D,UnityEngine cursorReprogramEnable
Результат UnityEngine.Texture2D

cursorSabotageEnable публичное свойство

public Texture2D,UnityEngine cursorSabotageEnable
Результат UnityEngine.Texture2D

cursorWalk публичное свойство

public Texture2D,UnityEngine cursorWalk
Результат UnityEngine.Texture2D

cursorWalkNotOk публичное свойство

public Texture2D,UnityEngine cursorWalkNotOk
Результат UnityEngine.Texture2D

gameBarBottom публичное свойство

public float gameBarBottom
Результат float

gameBarTop публичное свойство

public float gameBarTop
Результат float

mouseHitPointNow публичное статическое свойство

public static Vector3 mouseHitPointNow
Результат Vector3

selectedObject публичное свойство

public Transform selectedObject
Результат Transform

targetPosition публичное статическое свойство

public static Vector3 targetPosition
Результат Vector3