Skip to content

Commit d8babcf

Browse files
committed
update 20160518
1 parent 35bd966 commit d8babcf

File tree

379 files changed

+27219
-1464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

379 files changed

+27219
-1464
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/Library
77
/obj
88
/Build
9+
/Tutorials
910

1011
# ignore the following extension file
1112
*.svd
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* $File: CamInScreenSpace_Test.cs $
3+
* $Date: $
4+
* $Revision: $
5+
* $Creator: Jen-Chieh Shen $
6+
* $Notice: See LICENSE.txt for modification and distribution information $
7+
* Copyright (c) 2016 by Shen, Jen-Chieh $
8+
*/
9+
using UnityEngine;
10+
using System.Collections;
11+
using JCSUnity;
12+
13+
[RequireComponent(typeof(RectTransform))]
14+
public class CamInScreenSpace_Test : MonoBehaviour
15+
{
16+
17+
//----------------------
18+
// Public Variables
19+
20+
//----------------------
21+
// Private Variables
22+
private RectTransform mRectTransform = null;
23+
24+
//----------------------
25+
// Protected Variables
26+
27+
//========================================
28+
// setter / getter
29+
//------------------------------
30+
31+
//========================================
32+
// Unity's function
33+
//------------------------------
34+
private void Awake()
35+
{
36+
mRectTransform = this.GetComponent<RectTransform>();
37+
38+
}
39+
40+
private void Update()
41+
{
42+
print(JCS_GameManager.instance.GetJCSCamera().CheckInScreenSpace(mRectTransform));
43+
}
44+
45+
//========================================
46+
// Self-Define
47+
//------------------------------
48+
//----------------------
49+
// Public Functions
50+
51+
//----------------------
52+
// Protected Functions
53+
54+
//----------------------
55+
// Private Functions
56+
57+
}

Assets/FrameworkTest_Assets/Scripts/CamInScreenSpace_Test.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/**
2+
* $File: FitPushScreen_Test.cs $
3+
* $Date: $
4+
* $Revision: $
5+
* $Creator: Jen-Chieh Shen $
6+
* $Notice: See LICENSE.txt for modification and distribution information $
7+
* Copyright (c) 2016 by Shen, Jen-Chieh $
8+
*/
9+
using UnityEngine;
10+
using System.Collections;
11+
using JCSUnity;
12+
13+
public class FitPushScreen_Test : MonoBehaviour
14+
{
15+
16+
//----------------------
17+
// Public Variables
18+
19+
//----------------------
20+
// Private Variables
21+
[SerializeField]
22+
private RectTransform mPanelRectTransform = null;
23+
24+
//----------------------
25+
// Protected Variables
26+
27+
//========================================
28+
// setter / getter
29+
//------------------------------
30+
31+
//========================================
32+
// Unity's function
33+
//------------------------------
34+
private void Awake()
35+
{
36+
37+
}
38+
39+
private void Update()
40+
{
41+
42+
43+
if (JCS_Input.GetKey(KeyCode.D))
44+
{
45+
Vector3 newPos = this.mPanelRectTransform.localPosition;
46+
newPos.x += 10;
47+
this.mPanelRectTransform.localPosition = newPos;
48+
}
49+
if (JCS_Input.GetKey(KeyCode.A))
50+
{
51+
Vector3 newPos = this.mPanelRectTransform.localPosition;
52+
newPos.x -= 10;
53+
this.mPanelRectTransform.localPosition = newPos;
54+
}
55+
if (JCS_Input.GetKey(KeyCode.S))
56+
{
57+
Vector3 newPos = this.mPanelRectTransform.localPosition;
58+
newPos.y -= 10;
59+
this.mPanelRectTransform.localPosition = newPos;
60+
}
61+
if (JCS_Input.GetKey(KeyCode.W))
62+
{
63+
Vector3 newPos = this.mPanelRectTransform.localPosition;
64+
newPos.y += 10;
65+
this.mPanelRectTransform.localPosition = newPos;
66+
}
67+
68+
FitPushScreen();
69+
}
70+
71+
//========================================
72+
// Self-Define
73+
//------------------------------
74+
//----------------------
75+
// Public Functions
76+
77+
//----------------------
78+
// Protected Functions
79+
80+
//----------------------
81+
// Private Functions
82+
private void FitPushScreen()
83+
{
84+
Vector2 rectSize = mPanelRectTransform.sizeDelta;
85+
Vector3 panelPos = mPanelRectTransform.localPosition;
86+
87+
float halfSlotWidth = rectSize.x / 2 * mPanelRectTransform.localScale.x;
88+
float halfSlotHeight = rectSize.y / 2 * mPanelRectTransform.localScale.y;
89+
90+
float panelLeftBorder = panelPos.x - halfSlotWidth;
91+
float panelRightBorder = panelPos.x + halfSlotWidth;
92+
float panelTopBorder = panelPos.y + halfSlotHeight;
93+
float panelBottomBorder = panelPos.y - halfSlotHeight;
94+
95+
Camera cam = JCS_GameManager.instance.GetJCSCamera().GetCamera();
96+
Vector3 camPos = cam.transform.localPosition;
97+
98+
Vector2 camPosToScreen = cam.WorldToScreenPoint(camPos);
99+
100+
RectTransform appRect = JCS_UIManager.instance.GetAppRect();
101+
//Vector2 screenRect = appRect.sizeDelta;
102+
Vector2 screenRect = new Vector2(Screen.width, Screen.height);
103+
104+
float camLeftBorder = camPosToScreen.x - screenRect.x / 2;
105+
float camRightBorder = camPosToScreen.x + screenRect.x / 2;
106+
float camTopBorder = camPosToScreen.y + screenRect.y / 2;
107+
float camBottomBorder = camPosToScreen.y - screenRect.y / 2;
108+
109+
110+
111+
Vector3 newShowPoint = this.mPanelRectTransform.localPosition;
112+
113+
if (panelRightBorder > camRightBorder)
114+
{
115+
newShowPoint.x -= panelRightBorder - camRightBorder;
116+
}
117+
else if (panelLeftBorder < camLeftBorder)
118+
{
119+
newShowPoint.x -= panelLeftBorder - camLeftBorder;
120+
}
121+
122+
if (panelTopBorder > camTopBorder)
123+
{
124+
newShowPoint.y -= panelTopBorder - camTopBorder;
125+
}
126+
else if (panelBottomBorder < camBottomBorder)
127+
{
128+
newShowPoint.y -= panelBottomBorder - camBottomBorder;
129+
}
130+
131+
this.mPanelRectTransform.localPosition = newShowPoint;
132+
}
133+
134+
}

Assets/FrameworkTest_Assets/Scripts/FitPushScreen_Test.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* $File: FollowMouse_Test.cs $
3+
* $Date: $
4+
* $Revision: $
5+
* $Creator: Jen-Chieh Shen $
6+
* $Notice: See LICENSE.txt for modification and distribution information $
7+
* Copyright (c) 2016 by Shen, Jen-Chieh $
8+
*/
9+
using UnityEngine;
10+
using System.Collections;
11+
using JCSUnity;
12+
13+
public class FollowMouse_Test : MonoBehaviour
14+
{
15+
16+
//----------------------
17+
// Public Variables
18+
19+
//----------------------
20+
// Private Variables
21+
22+
//----------------------
23+
// Protected Variables
24+
25+
//========================================
26+
// setter / getter
27+
//------------------------------
28+
29+
//========================================
30+
// Unity's function
31+
//------------------------------
32+
private void Awake()
33+
{
34+
35+
}
36+
37+
private void Update()
38+
{
39+
//this.transform.position = Input.mousePosition;
40+
41+
Vector2 pos;
42+
Canvas myCanvas = JCS_UIManager.instance.GetJCSCanvas().GetCanvas();
43+
RectTransformUtility.ScreenPointToLocalPointInRectangle(myCanvas.transform as RectTransform, Input.mousePosition, myCanvas.worldCamera, out pos);
44+
transform.position = JCS_Input.CanvasMousePosition();
45+
46+
}
47+
48+
//========================================
49+
// Self-Define
50+
//------------------------------
51+
//----------------------
52+
// Public Functions
53+
54+
//----------------------
55+
// Protected Functions
56+
57+
//----------------------
58+
// Private Functions
59+
60+
}

Assets/FrameworkTest_Assets/Scripts/FollowMouse_Test.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* $File: Random_Test.cs $
3+
* $Date: $
4+
* $Revision: $
5+
* $Creator: Jen-Chieh Shen $
6+
* $Notice: See LICENSE.txt for modification and distribution information $
7+
* Copyright (c) 2016 by Shen, Jen-Chieh $
8+
*/
9+
using UnityEngine;
10+
using System.Collections;
11+
using JCSUnity;
12+
13+
public class Random_Test : MonoBehaviour
14+
{
15+
16+
//----------------------
17+
// Public Variables
18+
19+
//----------------------
20+
// Private Variables
21+
22+
//----------------------
23+
// Protected Variables
24+
25+
//========================================
26+
// setter / getter
27+
//------------------------------
28+
29+
//========================================
30+
// Unity's function
31+
//------------------------------
32+
private void Awake()
33+
{
34+
35+
}
36+
37+
private void Update()
38+
{
39+
if (JCS_Input.GetKeyDown(KeyCode.T))
40+
{
41+
print(JCS_TimeManager.GetCurrentTime());
42+
print(JCS_TimeManager.isAfternoon());
43+
}
44+
}
45+
46+
//========================================
47+
// Self-Define
48+
//------------------------------
49+
//----------------------
50+
// Public Functions
51+
52+
//----------------------
53+
// Protected Functions
54+
55+
//----------------------
56+
// Private Functions
57+
58+
}

Assets/FrameworkTest_Assets/Scripts/Random_Test.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)