Release









How do I use Release
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: InputToEvent.cs Copy
32     void Update()
33     {
34         if( DetectPointedAtGameObject )
35         {
36             goPointedAt = RaycastObject( Input.mousePosition );
37         }
38
39         if( Input.touchCount > 0 )
40         {
41             Touch touch = Input.GetTouch( 0 );
42             this.currentPos = touch.position;
43
44             if( touch.phase == TouchPhase.Began )
45             {
46                 Press( touch.position );
47             }
48             else if( touch.phase == TouchPhase.Ended )
49             {
50                 Release( touch.position );
51             }
52
53             return;
54         }
55
56         currentPos = Input.mousePosition;
57         if( Input.GetMouseButtonDown( 0 ) )
58         {
59             Press( Input.mousePosition );
60         }
61         if( Input.GetMouseButtonUp( 0 ) )
62         {
63             Release( Input.mousePosition );
64         }
65
66         if( Input.GetMouseButtonDown( 1 ) )
67         {
68             pressedPosition = Input.mousePosition;
69             lastGo = RaycastObject( pressedPosition );
70             if( lastGo != null )
71             {
72                 lastGo.SendMessage( "OnPressRight", SendMessageOptions.DontRequireReceiver );
73             }
74         }
75     }
File name: InputToEvent.cs Copy
90     private void Release( Vector2 screenPos )
91     {
92         if( lastGo != null )
93         {
94             GameObject currentGo = RaycastObject( screenPos );
95             if( currentGo == lastGo ) lastGo.SendMessage( "OnClick", SendMessageOptions.DontRequireReceiver );
96             lastGo.SendMessage( "OnRelease", SendMessageOptions.DontRequireReceiver );
97             lastGo = null;
98         }
99
100         pressedPosition = Vector2.zero;
101         this.Dragging = false;
102     }
File name: PawnMovement.cs Copy
57  public void OnSwitchEvent() {
58   if (!IsTurn()) return;
59   if (specialNodes[0] == null || specialNodes[1] == null) return;
60
61   if (moved && didSpecialMove) { // on next move
62    Debug.Log("released en passant" );
63    if (specialNodes[0] != null && specialNodes[0].Piece == piece) {
64     specialNodes[0].Piece = null;
65    }
66    specialNodes[0] = null;
67    specialNodes[1] = null;
68   }
69  }
File name: GameState.cs Copy
55  public void Release() {
56   state = GameStateType.WAITING;
57   GameManager.Instance.SwitchPlayer();
58  }
File name: GCPlayer.cs Copy
149  private void Drop() {
150   piece.Drop();
151   piece.Compute();
152   GameManager.Instance.GameState.Release();
153   piece = null;
154  }
File name: ScrollSnap.cs Copy
18  public class OnReleaseEvent : UnityEvent {}
File name: ScrollSnap.cs Copy
33  protected override void Awake() {
34   base.Awake();
35   actualIndex = startingIndex;
36   cellIndex = startingIndex;
37   this.onLerpComplete = new OnLerpCompleteEvent();
38   this.onRelease = new OnReleaseEvent();
39   this.scrollRect = GetComponent();
40   this.canvasGroup = GetComponent();
41   this.content = scrollRect.content;
42   this.cellSize = content.GetComponent().cellSize;
43   content.anchoredPosition = new Vector2(-cellSize.x * cellIndex, content.anchoredPosition.y);
44   int count = LayoutElementCount();
45   SetContentSize(count);
46
47   if(startingIndex < count) {
48    MoveToIndex(startingIndex);
49   }
50  }
File name: ScrollSnap.cs Copy
137  public void SnapToIndex(int newCellIndex) {
138   int maxIndex = CalculateMaxIndex();
139   if(wrapAround && maxIndex > 0) {
140    actualIndex += newCellIndex - cellIndex;
141    cellIndex = newCellIndex;
142    onLerpComplete.AddListener(WrapElementAround);
143   } else {
144    // when it's the same it means it tried to go out of bounds
145    if(newCellIndex >= 0 && newCellIndex <= maxIndex) {
146     actualIndex += newCellIndex - cellIndex;
147     cellIndex = newCellIndex;
148    }
149   }
150   onRelease.Invoke(cellIndex);
151   StartLerping();
152  }
File name: ScrollSnap.cs Copy
154  public void MoveToIndex(int newCellIndex) {
155   int maxIndex = CalculateMaxIndex();
156   if(newCellIndex >= 0 && newCellIndex <= maxIndex) {
157    actualIndex += newCellIndex - cellIndex;
158    cellIndex = newCellIndex;
159   }
160   onRelease.Invoke(cellIndex);
161   content.anchoredPosition = CalculateTargetPoisition(cellIndex);
162  }
File name: ScrollSnap.cs Copy
164  void StartLerping() {
165   releasedPosition = content.anchoredPosition;
166   targetPosition = CalculateTargetPoisition(cellIndex);
167   lerpStartedAt = DateTime.Now;
168   canvasGroup.blocksRaycasts = false;
169   isLerping = true;
170  }

Download file with original file name:Release

Release 146 lượt xem

Gõ tìm kiếm nhanh...