https://github.com/kuritaro1122/clampcamera2d
[Beta]オブジェクトの座標を自然に制限する。
https://github.com/kuritaro1122/clampcamera2d
csharp unity unity-scripts
Last synced: about 1 month ago
JSON representation
[Beta]オブジェクトの座標を自然に制限する。
- Host: GitHub
- URL: https://github.com/kuritaro1122/clampcamera2d
- Owner: kuritaro1122
- License: unlicense
- Created: 2021-09-14T15:04:47.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-04-01T08:02:36.000Z (about 4 years ago)
- Last Synced: 2025-01-07T22:51:33.711Z (over 1 year ago)
- Topics: csharp, unity, unity-scripts
- Language: C#
- Homepage:
- Size: 52.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ClampCamera2D
オブジェクトの座標を自然に制限する。
# 【HyperNovaで使用している様子】

# 【簡易リファレンス】
**Public 変数**
* Vector3 Horizontal
* Vector3 Vertical
**Public 関数**
* Vector3 LocalHorizontal (Vector3 pos, bool local)
* Vector3 LocalVertical (Vector3 pos, bool local)
* Vector3 TransformPosition (Vector3 localPos) // localPos => 0 ~ 1
* Vector3 InverseTransformPosition (Vector3 pos)
* Vector3 ClampPosition (Vector3 pos, bool lockLocalZ = true)
* void UpdateEdgePoint ()
**Inspector 変数**
* [GameObject]
- Camera cam
- Transform target
* [Plane Setting]
- Vector3 horizontal
- Vector3 vertical
- bool axisOrthogonal
- Vector3 center
- bool lock Center
* [Margin]
- rightMargin
- leftMargin
- upMargin
- downMargin
* [Option]
- bool clampOnUpdate
- bool updatePlane
* [Gizmos]
- bool drawCameraRange
- bool drawPlaneAxis
- float drawAxisSize

# Example
```
using From3DTo2D.ClampCamera;
public class Sample : MonoBehaviour {
public ClampCamera2D cc2d;
public float speed = 10f;
void Movement(Transform _transform, Vector2 stick) { //Call on Update()
Vector3 pos = _transform.position;
pos += speed * (cc2d.LocalHorizontal(pos) * stick.x + cc2d.LocalVertical(pos) * stick.y) * Time.deltaTime;
pos = cc2d.ClampPosition(position, false);
}
}
```