本文整理汇总了C#中tk2dCamera类的典型用法代码示例。如果您正苦于以下问题:C# tk2dCamera类的具体用法?C# tk2dCamera怎么用?C# tk2dCamera使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
tk2dCamera类属于命名空间,在下文中一共展示了tk2dCamera类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ForTk2dCamera
public static tk2dSpriteCollectionSize ForTk2dCamera(tk2dCamera camera)
{
tk2dSpriteCollectionSize size = new tk2dSpriteCollectionSize();
tk2dCameraSettings cameraSettings = camera.SettingsRoot.CameraSettings;
if (cameraSettings.projection == tk2dCameraSettings.ProjectionType.Orthographic)
{
tk2dCameraSettings.OrthographicType orthographicType = cameraSettings.orthographicType;
if (orthographicType != tk2dCameraSettings.OrthographicType.PixelsPerMeter)
{
if (orthographicType != tk2dCameraSettings.OrthographicType.OrthographicSize)
{
return size;
}
}
else
{
size.type = Type.PixelsPerMeter;
size.pixelsPerMeter = cameraSettings.orthographicPixelsPerMeter;
return size;
}
size.type = Type.Explicit;
size.height = camera.nativeResolutionHeight;
size.orthoSize = cameraSettings.orthographicSize;
return size;
}
if (cameraSettings.projection == tk2dCameraSettings.ProjectionType.Perspective)
{
size.type = Type.PixelsPerMeter;
size.pixelsPerMeter = 100f;
}
return size;
}
示例2: Initalize
//tk2dCamera cam
public void Initalize(tk2dCamera cam){
curtain = transform.GetChild(0).GetComponent<Curtain_>();
ani = transform.GetChild(1).GetComponent<LoadingAni_>();
curtain.Initialize(cam.nativeResolutionWidth, cam.nativeResolutionHeight, cam.CameraSettings.orthographicPixelsPerMeter / 20);
ani.Initialize(cam.nativeResolutionWidth, cam.nativeResolutionHeight, cam.CameraSettings.orthographicPixelsPerMeter);
enabled = true;
}
示例3: Start
// Use this for initialization
void Start()
{
score=0;
curHP=totalHP;
preFireTime=Time.time;
m_camera=(tk2dCamera)FindObjectOfType(typeof(tk2dCamera));
gunPort=GetComponent<tk2dSpriteAttachPoint>().attachPoints;
}
示例4: Start
private void Start() {
instance = this;
//us = transform;
cam = GetComponent<tk2dCamera>();
//minZoom = cam.ZoomFactor;
targets = new Transform[maxTargets];
}
示例5: Initalize
//tk2dCamera cam
public void Initalize(tk2dCamera cam){
isInit = true;
enabled = true;
curtain = transform.GetChild(0).GetComponent<Curtain_>();
ani = transform.GetChild(1).GetComponent<LoadingAni_>();
curtain.Initialize(cam.forceResolution.x, cam.forceResolution.y, cam.CameraSettings.orthographicPixelsPerMeter);
ani.Initialize(cam.forceResolution.x, cam.forceResolution.y, cam.CameraSettings.orthographicPixelsPerMeter);
}
示例6: Start
void Start()
{
thisCamera = gameObject.GetComponent<tk2dCamera> ();
playerControl = GameObject.FindGameObjectWithTag("Skateboard").GetComponent<PlayerControl> ();
// maxZoom = 1 - maxZoom;
// minZoom = 1 - minZoom;
//minimumZoom = thisCamera.ZoomFactor;
}
示例7: Awake
void Awake() {
if(mInstance == null) {
mInstance = this;
//init stuff
mCam = GetComponentInChildren<tk2dCamera>();
mCurDelay = delay;
}
else {
DestroyImmediate(gameObject);
}
}
示例8: GetOffsetForOverride
private Vector2 GetOffsetForOverride(tk2dCamera settings, tk2dCameraResolutionOverride currentOverride, Vector2 scale, float width, float height)
{
Vector2 zero = Vector2.zero;
if (currentOverride == null)
{
return zero;
}
tk2dCameraResolutionOverride.FitMode fitMode = currentOverride.fitMode;
if ((fitMode != tk2dCameraResolutionOverride.FitMode.Constant) && (fitMode == tk2dCameraResolutionOverride.FitMode.Center))
{
if (settings.cameraSettings.orthographicOrigin == tk2dCameraSettings.OrthographicOrigin.BottomLeft)
{
zero = new Vector2(Mathf.Round(((settings.nativeResolutionWidth * scale.x) - width) / 2f), Mathf.Round(((settings.nativeResolutionHeight * scale.y) - height) / 2f));
}
return zero;
}
return -currentOverride.offsetPixels;
}
示例9: ForTk2dCamera
/// <summary>
/// Use when you need the sprite to be pixel perfect on a specific tk2dCamera.
/// </summary>
public static tk2dSpriteCollectionSize ForTk2dCamera( tk2dCamera camera ) {
tk2dSpriteCollectionSize s = new tk2dSpriteCollectionSize();
tk2dCameraSettings cameraSettings = camera.SettingsRoot.CameraSettings;
if (cameraSettings.projection == tk2dCameraSettings.ProjectionType.Orthographic) {
switch (cameraSettings.orthographicType) {
case tk2dCameraSettings.OrthographicType.PixelsPerMeter:
s.type = Type.PixelsPerMeter;
s.pixelsPerMeter = cameraSettings.orthographicPixelsPerMeter;
break;
case tk2dCameraSettings.OrthographicType.OrthographicSize:
s.type = Type.Explicit;
s.height = camera.nativeResolutionHeight;
s.orthoSize = cameraSettings.orthographicSize;
break;
}
}
else if (cameraSettings.projection == tk2dCameraSettings.ProjectionType.Perspective) {
s.type = Type.PixelsPerMeter;
s.pixelsPerMeter = 100; // some random value
}
return s;
}
示例10: UpdateCameraMatrix
/// <summary>
/// Updates the camera matrix to ensure 1:1 pixel mapping
/// Or however the override is set up.
/// </summary>
public void UpdateCameraMatrix()
{
Upgrade();
if (!this.viewportClippingEnabled)
inst = this;
Camera unityCamera = UnityCamera;
tk2dCamera settings = SettingsRoot;
tk2dCameraSettings inheritedCameraSettings = settings.CameraSettings;
if (unityCamera.rect != cameraSettings.rect) unityCamera.rect = cameraSettings.rect;
// Projection type is inherited from base camera
_targetResolution = GetScreenPixelDimensions(settings);
if (inheritedCameraSettings.projection == tk2dCameraSettings.ProjectionType.Perspective) {
if (unityCamera.orthographic == true) unityCamera.orthographic = false;
float fov = Mathf.Min(179.9f, inheritedCameraSettings.fieldOfView / Mathf.Max(0.001f, ZoomFactor));
if (unityCamera.fieldOfView != fov) unityCamera.fieldOfView = fov;
_screenExtents.Set( -unityCamera.aspect, -1, unityCamera.aspect * 2, 2 );
_nativeScreenExtents = _screenExtents;
unityCamera.ResetProjectionMatrix();
}
else {
if (unityCamera.orthographic == false) unityCamera.orthographic = true;
// Find an override if necessary
Matrix4x4 m = GetProjectionMatrixForOverride( settings, settings.CurrentResolutionOverride, _targetResolution.x, _targetResolution.y, true, out _screenExtents, out _nativeScreenExtents );
#if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_1)
// Windows phone?
if (Application.platform == RuntimePlatform.WP8Player &&
(Screen.orientation == ScreenOrientation.LandscapeLeft || Screen.orientation == ScreenOrientation.LandscapeRight)) {
float angle = (Screen.orientation == ScreenOrientation.LandscapeRight) ? 90.0f : -90.0f;
Matrix4x4 m2 = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, angle), Vector3.one);
m = m2 * m;
}
#endif
if (unityCamera.projectionMatrix != m) {
unityCamera.projectionMatrix = m;
}
}
}
示例11: GetOffsetForOverride
Vector2 GetOffsetForOverride(tk2dCamera settings, tk2dCameraResolutionOverride currentOverride, Vector2 scale, float width, float height)
{
Vector2 offset = Vector2.zero;
if (currentOverride == null) {
return offset;
}
switch (currentOverride.fitMode) {
case tk2dCameraResolutionOverride.FitMode.Center:
if (settings.cameraSettings.orthographicOrigin == tk2dCameraSettings.OrthographicOrigin.BottomLeft) {
offset = new Vector2(Mathf.Round((settings.nativeResolutionWidth * scale.x - width ) / 2.0f),
Mathf.Round((settings.nativeResolutionHeight * scale.y - height) / 2.0f));
}
break;
default:
case tk2dCameraResolutionOverride.FitMode.Constant:
offset = -currentOverride.offsetPixels;
break;
}
return offset;
}
示例12: Awake
// Use this for initialization
void Awake()
{
tkCam = GetComponent<tk2dCamera>();
}
示例13: Awake
void Awake()
{
_instance = this;
_transform = transform;
if (GameCamera == null)
GameCamera = GetComponent<Camera>();
if (GameCamera == null)
Debug.LogError("Unity Camera not set and not found on the GameObject: " + gameObject.name);
#if PC2D_TK2D_SUPPORT
Tk2dCam = GetComponent<tk2dCamera>();
#endif
switch (Axis)
{
case MovementAxis.XY:
Vector3H = vector => vector.x;
Vector3V = vector => vector.y;
Vector3D = vector => vector.z;
VectorHV = (h, v) => new Vector3(h, v, 0);
VectorHVD = (h, v, d) => new Vector3(h, v, d);
break;
case MovementAxis.XZ:
Vector3H = vector => vector.x;
Vector3V = vector => vector.z;
Vector3D = vector => vector.y;
VectorHV = (h, v) => new Vector3(h, 0, v);
VectorHVD = (h, v, d) => new Vector3(h, d, v);
break;
case MovementAxis.YZ:
Vector3H = vector => vector.z;
Vector3V = vector => vector.y;
Vector3D = vector => vector.x;
VectorHV = (h, v) => new Vector3(0, v, h);
VectorHVD = (h, v, d) => new Vector3(d, v, h);
break;
}
// Remove empty targets
for (int i = 0; i < CameraTargets.Count; i++)
{
if (CameraTargets[i].TargetTransform == null)
{
CameraTargets.RemoveAt(i);
}
}
ScreenSizeInWorldCoordinates = Utils.GetScreenSizeInWorldCoords(GameCamera, Mathf.Abs(Vector3D(_transform.localPosition)));
_cameraDepthPos = Vector3D(_transform.localPosition);
_originalCameraDepthSign = Mathf.Sign(_cameraDepthPos);
_transform.parent = new GameObject(gameObject.name + " Container").transform;
// Center on target
if (CenterTargetOnStart && CameraTargets.Count > 0)
{
var targetPos = GetTargetsWeightedMidPoint(CameraTargets);
var cameraTargetPositionX = FollowHorizontal ? Vector3H(targetPos) : Vector3H(_transform.localPosition);
var cameraTargetPositionY = FollowVertical ? Vector3V(targetPos) : Vector3V(_transform.localPosition);
targetPos = VectorHV(cameraTargetPositionX, cameraTargetPositionY);
targetPos += VectorHV(OverallOffset.x, OverallOffset.y);
MoveCameraInstantlyToPosition(targetPos);
}
else
{
_cameraTargetPosition = _transform.localPosition;
_cameraTargetHorizontalPositionSmoothed = Vector3H(_cameraTargetPosition);
_previousCameraTargetHorizontalPositionSmoothed = _cameraTargetHorizontalPositionSmoothed;
_cameraTargetVerticalPositionSmoothed = Vector3V(_cameraTargetPosition);
_previousCameraTargetVerticalPositionSmoothed = _cameraTargetVerticalPositionSmoothed;
}
}
示例14: Start
void Start()
{
//Debug.Log("EnemyPlaneController:Start() - direction = " + direction);
objCamera = (tk2dCamera) GameObject.FindWithTag("MainCamera").GetComponent<tk2dCamera>();
objSprite = GetComponent<tk2dAnimatedSprite>();
trans = transform;
health = maxHealth;
trailTrans = transform.root.Find("TrailPosition");
launcherTrans = transform.root.Find("LauncherPosition");
parTrail = (GameObject)Instantiate(parVaporTrail, trailTrans.position, Quaternion.identity);
if (direction == PlaneDirection.RIGHT)
{
objSprite.FlipX();
}
}
示例15: InitCamera
/// <summary>
/// Inits the camera.
/// </summary>
public static void InitCamera()
{
tkCamera = Camera.main.GetComponent<tk2dCamera>();
}