Last active
June 30, 2017 18:48
-
-
Save muzudho/1bdb3cbc8d4cc40fb9efd4151548b415 to your computer and use it in GitHub Desktop.
Unity 接地判定の線とか、見えない境界とか、見たくなったときは LineRendererで画面に線を引く ref: http://qiita.com/muzudho1/items/e6b02553f8186d80fb53
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// 表示区画の枠 | |
/// </summary> | |
[MenuItem("Tool/RefreshLineFrame")] | |
static void RefreshLineFrame() | |
{ | |
// 枠 | |
lineFrame = GameObject.Find("LineFrame"); | |
transform_lineFrame = lineFrame.GetComponent<Transform>(); | |
LineRenderer lineRenderer = lineFrame.GetComponent<LineRenderer>(); | |
float lineWidth = lineRenderer.widthMultiplier; | |
float viewWidthHalf = config.pixelOfViewWidth / 2; | |
lineRenderer.SetPositions(new Vector3[] { | |
new Vector3(-0.8f-lineWidth-viewWidthHalf,0.8f+lineWidth,-9f), | |
new Vector3(0.8f+lineWidth+viewWidthHalf,0.8f+lineWidth,-9f), | |
new Vector3(0.8f+lineWidth+viewWidthHalf,-0.8f-lineWidth,-9f), | |
new Vector3(-0.8f-lineWidth-viewWidthHalf,-0.8f-lineWidth,-9f), | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GameObject groundedLine_go = GameObject.Find("GroundedLine"); | |
LineRenderer line = groundedLine_go.GetComponent<LineRenderer>(); | |
line.SetPositions(new Vector3[] { | |
new Vector3(begin.x, begin.y, line.transform.position.z), | |
new Vector3(end.x, end.y, line.transform.position.z) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// 表示区画の枠 | |
/// </summary> | |
[MenuItem("Tool/RefreshLineFrame")] | |
static void RefreshLineFrame() | |
{ | |
Config config = (Config)GameObject.Find("Config").GetComponent<MonoBehaviour>(); | |
GameObject lineFrame = GameObject.Find("LineFrame"); | |
Transform transform = lineFrame.GetComponent<Transform>(); | |
LineRenderer lineRenderer = lineFrame.GetComponent<LineRenderer>(); | |
float lineWidthHalf = lineRenderer.widthMultiplier / 2; | |
float viewWidthHalf = config.pixelOfViewWidth / 2; | |
float viewHeightHalf = config.GetPixelOfSectionHeight() / 2; | |
lineRenderer.SetPositions(new Vector3[] { | |
new Vector3(-lineWidthHalf-viewWidthHalf,lineWidthHalf+viewHeightHalf,-9f), | |
new Vector3(lineWidthHalf+viewWidthHalf,lineWidthHalf+viewHeightHalf,-9f), | |
new Vector3(lineWidthHalf+viewWidthHalf,-lineWidthHalf-viewHeightHalf,-9f), | |
new Vector3(-lineWidthHalf-viewWidthHalf,-lineWidthHalf-viewHeightHalf,-9f), | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// 表示区画の枠 | |
/// </summary> | |
[MenuItem("Tool/RefreshLineFrame")] | |
static void RefreshLineFrame() | |
{ | |
Config config = (Config)GameObject.Find("Config").GetComponent<MonoBehaviour>(); | |
GameObject lineFrame = GameObject.Find("LineFrame"); | |
Transform transform = lineFrame.GetComponent<Transform>(); | |
LineRenderer lineRenderer = lineFrame.GetComponent<LineRenderer>(); | |
float lineWidthHalf = lineRenderer.widthMultiplier / 2; | |
float viewWidthHalf = config.pixelOfViewWidth / 2; | |
float viewHeightHalf = config.GetPixelOfSectionHeight() / 2; | |
lineRenderer.SetPositions(new Vector3[] { | |
new Vector3(-lineWidthHalf-viewWidthHalf,lineWidthHalf+viewHeightHalf,-9f), | |
new Vector3(lineWidthHalf+viewWidthHalf,lineWidthHalf+viewHeightHalf,-9f), | |
new Vector3(lineWidthHalf+viewWidthHalf,-lineWidthHalf-viewHeightHalf,-9f), | |
new Vector3(-lineWidthHalf-viewWidthHalf,-lineWidthHalf-viewHeightHalf,-9f), | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment