本文整理汇总了C#中tk2dCamera类的典型用法代码示例。如果您正苦于以下问题:C# tk2dCamera类的具体用法?C# tk2dCamera怎么用?C# tk2dCamera使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
tk2dCamera类属于命名空间,在下文中一共展示了tk2dCamera类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Lessica,项目名称:Something-of-SHIPWAR-GAMES,代码行数:32,代码来源:tk2dSpriteCollectionSize.cs
示例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;
}
开发者ID:21garam,项目名称:SW_Maestro,代码行数:8,代码来源:Loading_.cs
示例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;
}
开发者ID:projectindex,项目名称:shootGame,代码行数:9,代码来源:Player.cs
示例4: Start
private void Start() {
instance = this;
//us = transform;
cam = GetComponent<tk2dCamera>();
//minZoom = cam.ZoomFactor;
targets = new Transform[maxTargets];
}
开发者ID:smclallen,项目名称:Galactic_Parcel_Service,代码行数:8,代码来源:CameraFollow.cs
示例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);
}
开发者ID:21garam,项目名称:SW_Maestro,代码行数:9,代码来源:Loading_.cs
示例6: Start
void Start()
{
thisCamera = gameObject.GetComponent<tk2dCamera> ();
playerControl = GameObject.FindGameObjectWithTag("Skateboard").GetComponent<PlayerControl> ();
// maxZoom = 1 - maxZoom;
// minZoom = 1 - minZoom;
//minimumZoom = thisCamera.ZoomFactor;
}
开发者ID:jrf0110,项目名称:skeleboarder,代码行数:10,代码来源:CameraZoomer.cs
示例7: Awake
void Awake() {
if(mInstance == null) {
mInstance = this;
//init stuff
mCam = GetComponentInChildren<tk2dCamera>();
mCurDelay = delay;
}
else {
DestroyImmediate(gameObject);
}
}
开发者ID:PushoN,项目名称:game-off-2013,代码行数:13,代码来源:CameraController.cs
示例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;
}
开发者ID:Lessica,项目名称:Something-of-SHIPWAR-GAMES,代码行数:18,代码来源:tk2dCamera.cs
示例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;
}
开发者ID:Eddikos,项目名称:public-access-1,代码行数:25,代码来源:tk2dSpriteCollectionSize.cs
示例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;
}
}
}
开发者ID:rbrt,项目名称:heritagequest,代码行数:48,代码来源:tk2dCamera.cs
示例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;
}
开发者ID:rbrt,项目名称:heritagequest,代码行数:22,代码来源:tk2dCamera.cs
示例12: Awake
// Use this for initialization
void Awake()
{
tkCam = GetComponent<tk2dCamera>();
}
开发者ID:netpro2k,项目名称:root-route,代码行数:5,代码来源:CameraHandler.cs
示例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;
}
}
开发者ID:EunoiaGames,项目名称:MTW,代码行数:74,代码来源:ProCamera2D.cs
示例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();
}
}
开发者ID:jpann,项目名称:MissileDefense,代码行数:19,代码来源:EnemyPlaneController.cs
示例15: InitCamera
/// <summary>
/// Inits the camera.
/// </summary>
public static void InitCamera()
{
tkCamera = Camera.main.GetComponent<tk2dCamera>();
}
开发者ID:zhaoguo20002,项目名称:WuGong,代码行数:7,代码来源:Statics.cs
示例16: GetScreenPixelDimensions
Vector2 GetScreenPixelDimensions(tk2dCamera settings)
{
Vector2 dimensions = new Vector2(ScreenCamera.pixelWidth, ScreenCamera.pixelHeight);
#if UNITY_EDITOR
// This bit here allocates memory, but only runs in the editor
float gameViewPixelWidth = 0, gameViewPixelHeight = 0;
float gameViewAspect = 0;
settings.useGameWindowResolutionInEditor = false;
if (Editor__GetGameViewSize( out gameViewPixelWidth, out gameViewPixelHeight, out gameViewAspect)) {
if (gameViewPixelWidth != 0 && gameViewPixelHeight != 0) {
if (!settings.useGameWindowResolutionInEditor ||
settings.gameWindowResolution.x != gameViewPixelWidth ||
settings.gameWindowResolution.y != gameViewPixelHeight) {
settings.useGameWindowResolutionInEditor = true;
settings.gameWindowResolution.x = gameViewPixelWidth;
settings.gameWindowResolution.y = gameViewPixelHeight;
}
dimensions.x = settings.gameWindowResolution.x;
dimensions.y = settings.gameWindowResolution.y;
}
}
if (!settings.useGameWindowResolutionInEditor && settings.forceResolutionInEditor)
{
dimensions.x = settings.forceResolution.x;
dimensions.y = settings.forceResolution.y;
}
#endif
return dimensions;
}
开发者ID:rbrt,项目名称:heritagequest,代码行数:32,代码来源:tk2dCamera.cs
示例17: DrawOverrideGUI
void DrawOverrideGUI(tk2dCamera _camera)
{
var frameBorderStyle = EditorStyles.textField;
EditorGUIUtility.LookLikeControls(64);
tk2dCamera _target = _camera.SettingsRoot;
if (_target.CameraSettings.projection == tk2dCameraSettings.ProjectionType.Perspective) {
tk2dGuiUtility.InfoBox("Overrides not supported with perspective camera.", tk2dGuiUtility.WarningLevel.Info);
}
else {
GUI.enabled = _target == _camera;
tk2dCameraResolutionOverride usedOverride = _target.CurrentResolutionOverride;
if (_target.resolutionOverride.Length == 0) {
EditorGUILayout.HelpBox("There are no overrides on this tk2dCamera.\n\nThe camera will always scale itself to be pixel perfect at any resolution. " +
"Add an override if you wish to change this behaviour.", MessageType.Warning);
}
else {
EditorGUILayout.HelpBox("Matching is performed from top to bottom. The first override matching the current resolution will be used.", MessageType.Info);
}
System.Action<int> deferredAction = null;
for (int i = 0; i < _target.resolutionOverride.Length; ++i)
{
tk2dCameraResolutionOverride ovr = _target.resolutionOverride[i];
EditorGUILayout.BeginVertical(frameBorderStyle);
GUILayout.Space(8);
GUILayout.BeginHorizontal();
ovr.name = EditorGUILayout.TextField("Name", ovr.name);
GUI.enabled = (i != _target.resolutionOverride.Length - 1);
if (GUILayout.Button("", tk2dEditorSkin.SimpleButton("btn_down")))
{
int idx = i;
deferredAction = delegate(int q) {
_target.resolutionOverride[idx] = _target.resolutionOverride[idx+1];
_target.resolutionOverride[idx+1] = ovr;
};
}
GUI.enabled = (i != 0);
if (GUILayout.Button("", tk2dEditorSkin.SimpleButton("btn_up")))
{
int idx = i;
deferredAction = delegate(int q) {
_target.resolutionOverride[idx] = _target.resolutionOverride[idx-1];
_target.resolutionOverride[idx-1] = ovr;
};
}
GUI.enabled = true;
if (GUILayout.Button("", tk2dEditorSkin.GetStyle("TilemapDeleteItem"))) {
int idx = i;
deferredAction = delegate(int q) {
List<tk2dCameraResolutionOverride> list = new List<tk2dCameraResolutionOverride>(_target.resolutionOverride);
list.RemoveAt(idx);
_target.resolutionOverride = list.ToArray();
};
}
GUILayout.EndHorizontal();
ovr.matchBy = (tk2dCameraResolutionOverride.MatchByType)EditorGUILayout.EnumPopup("Match By", ovr.matchBy);
int tmpIndent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
switch (ovr.matchBy) {
case tk2dCameraResolutionOverride.MatchByType.Wildcard:
break;
case tk2dCameraResolutionOverride.MatchByType.Resolution:
Vector2 res = new Vector2(ovr.width, ovr.height);
res = ResolutionControl(" ", res);
ovr.width = (int)res.x;
ovr.height = (int)res.y;
break;
case tk2dCameraResolutionOverride.MatchByType.AspectRatio:
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(" ");
ovr.aspectRatioNumerator = EditorGUILayout.FloatField(ovr.aspectRatioNumerator, GUILayout.Width(40));
GUILayout.Label(":", GUILayout.ExpandWidth(false));
ovr.aspectRatioDenominator = EditorGUILayout.FloatField(ovr.aspectRatioDenominator, GUILayout.Width(40));
GUILayout.EndHorizontal();
break;
}
EditorGUI.indentLevel = tmpIndent;
ovr.autoScaleMode = (tk2dCameraResolutionOverride.AutoScaleMode)EditorGUILayout.EnumPopup("Auto Scale", ovr.autoScaleMode);
if (ovr.autoScaleMode == tk2dCameraResolutionOverride.AutoScaleMode.None)
{
EditorGUI.indentLevel++;
ovr.scale = EditorGUILayout.FloatField("Scale", ovr.scale);
EditorGUI.indentLevel--;
}
if (ovr.autoScaleMode == tk2dCameraResolutionOverride.AutoScaleMode.StretchToFit)
{
string msg = "The native resolution image will be stretched to fit the target display. " +
"Image quality will suffer if non-uniform scaling occurs.";
//.........这里部分代码省略.........
开发者ID:rbrt,项目名称:heritagequest,代码行数:101,代码来源:tk2dCameraEditor.cs
示例18: Start
// Use this for initialization
void Start()
{
cam = GetComponent<tk2dCamera>();
}
开发者ID:andi2,项目名称:ludum-dare-26,代码行数:5,代码来源:zoomtest.cs
示例19: DrawCameraGUI
void DrawCameraGUI(tk2dCamera target, bool complete)
{
bool allowProjectionParameters = target.SettingsRoot == target;
bool oldGuiEnabled = GUI.enabled;
SerializedObject so = this.serializedObject;
SerializedObject cam = new SerializedObject( target.camera );
SerializedProperty m_ClearFlags = cam.FindProperty("m_ClearFlags");
SerializedProperty m_BackGroundColor = cam.FindProperty("m_BackGroundColor");
SerializedProperty m_CullingMask = cam.FindProperty("m_CullingMask");
SerializedProperty m_TargetTexture = cam.FindProperty("m_TargetTexture");
SerializedProperty m_Near = cam.FindProperty("near clip plane");
SerializedProperty m_Far = cam.FindProperty("far clip plane");
SerializedProperty m_Depth = cam.FindProperty("m_Depth");
SerializedProperty m_RenderingPath = cam.FindProperty("m_RenderingPath");
SerializedProperty m_HDR = cam.FindProperty("m_HDR");
if (complete) {
EditorGUILayout.PropertyField( m_ClearFlags );
EditorGUILayout.PropertyField( m_BackGroundColor );
EditorGUILayout.PropertyField( m_CullingMask );
EditorGUILayout.Space();
}
tk2dCameraSettings cameraSettings = target.CameraSettings;
tk2dCameraSettings inheritedSettings = target.SettingsRoot.CameraSettings;
TransparencySortMode transparencySortMode = inheritedSettings.transparencySortMode;
GUI.enabled &= allowProjectionParameters;
inheritedSettings.projection = (tk2dCameraSettings.ProjectionType)EditorGUILayout.EnumPopup("Projection", inheritedSettings.projection);
EditorGUI.indentLevel++;
if (inheritedSettings.projection == tk2dCameraSettings.ProjectionType.Orthographic) {
inheritedSettings.orthographicType = (tk2dCameraSettings.OrthographicType)EditorGUILayout.EnumPopup("Type", inheritedSettings.orthographicType);
switch (inheritedSettings.orthographicType) {
case tk2dCameraSettings.OrthographicType.OrthographicSize:
inheritedSettings.orthographicSize = Mathf.Max( 0.001f, EditorGUILayout.FloatField("Orthographic Size", inheritedSettings.orthographicSize) );
break;
case tk2dCameraSettings.OrthographicType.PixelsPerMeter:
inheritedSettings.orthographicPixelsPerMeter = Mathf.Max( 0.001f, EditorGUILayout.FloatField("Pixels per Meter", inheritedSettings.orthographicPixelsPerMeter) );
break;
}
inheritedSettings.orthographicOrigin = (tk2dCameraSettings.OrthographicOrigin)EditorGUILayout.EnumPopup("Origin", inheritedSettings.orthographicOrigin);
}
else if (inheritedSettings.projection == tk2dCameraSettings.ProjectionType.Perspective) {
inheritedSettings.fieldOfView = EditorGUILayout.Slider("Field of View", inheritedSettings.fieldOfView, 1, 179);
transparencySortMode = (TransparencySortMode)EditorGUILayout.EnumPopup("Sort mode", transparencySortMode);
}
EditorGUI.indentLevel--;
GUI.enabled = oldGuiEnabled;
if (complete) {
EditorGUILayout.Space();
GUILayout.Label("Clipping Planes");
GUILayout.BeginHorizontal();
GUILayout.Space(14);
GUILayout.Label("Near");
if (m_Near != null) EditorGUILayout.PropertyField(m_Near, GUIContent.none, GUILayout.Width(60) );
GUILayout.Label("Far");
if (m_Far != null) EditorGUILayout.PropertyField(m_Far, GUIContent.none, GUILayout.Width(60) );
GUILayout.EndHorizontal();
cameraSettings.rect = EditorGUILayout.RectField("Normalized View Port Rect", cameraSettings.rect);
EditorGUILayout.Space();
if (m_Depth != null) EditorGUILayout.PropertyField(m_Depth);
if (m_RenderingPath != null) EditorGUILayout.PropertyField(m_RenderingPath);
if (m_TargetTexture != null) EditorGUILayout.PropertyField(m_TargetTexture);
if (m_HDR != null) EditorGUILayout.PropertyField(m_HDR);
}
cam.ApplyModifiedProperties();
so.ApplyModifiedProperties();
if (transparencySortMode != inheritedSettings.transparencySortMode) {
inheritedSettings.transparencySortMode = transparencySortMode;
target.camera.transparencySortMode = transparencySortMode; // Change immediately in the editor
EditorUtility.SetDirty(target);
EditorUtility.SetDirty(target.camera);
}
}
开发者ID:rbrt,项目名称:heritagequest,代码行数:80,代码来源:tk2dCameraEditor.cs
示例20: UpdateCameraMatrix
/// <summary>
/// Updates the camera matrix to ensure 1:1 pixel mapping
/// </summary>
public void UpdateCameraMatrix()
{
if (!this.viewportClippingEnabled)
inst = this;
if (!mainCamera.orthographic)
{
// Must be orthographic
Debug.LogError("tk2dCamera must be orthographic");
mainCamera.orthographic = true;
}
tk2dCamera settings = inheritSettings != null ? inheritSettings : this;
bool viewportClippingEnabled = this.viewportClippingEnabled && this.screenCamera != null && this.screenCamera.rect == unitRect;
Camera screenCamera = viewportClippingEnabled ? this.screenCamera : mainCamera;
float pixelWidth = screenCamera.pixelWidth;
float pixelHeight = screenCamera.pixelHeight;
#if UNITY_EDITOR
if (settings.forceResolutionInEditor)
{
pixelWidth = settings.forceResolution.x;
pixelHeight = settings.forceResolution.y;
}
#endif
_targetResolution = new Vector2(pixelWidth, pixelHeight);
// Find an override if necessary
if (!settings.enableResolutionOverrides)
currentResolutionOverride = null;
if (settings.enableResolutionOverrides &&
(currentResolutionOverride == null ||
(currentResolutionOverride != null && (currentResolutionOverride.width != pixelWidth || currentResolutionOverride.height != pixelHeight))
))
{
currentResolutionOverride = null;
// find one if it matches the current resolution
if (settings.resolutionOverride != null)
{
foreach (var ovr in settings.resolutionOverride)
{
if (ovr.Match((int)pixelWidth, (int)pixelHeight))
{
currentResolutionOverride = ovr;
break;
}
}
}
}
Vector2 scale = new Vector2(1, 1);
Vector2 offset = new Vector2(0, 0);
float s = 0.0f;
if (currentResolutionOverride != null)
{
switch (currentResolutionOverride.autoScaleMode)
{
case tk2dCameraResolutionOverride.AutoScaleMode.FitHeight:
s = pixelHeight / nativeResolutionHeight;
scale.Set(s, s);
break;
case tk2dCameraResolutionOverride.AutoScaleMode.FitWidth:
s = pixelWidth / nativeResolutionWidth;
scale.Set(s, s);
break;
case tk2dCameraResolutionOverride.AutoScaleMode.FitVisible:
case tk2dCameraResolutionOverride.AutoScaleMode.PixelPerfectFit:
float nativeAspect = (float)nativeResolutionWidth / nativeResolutionHeight;
float currentAspect = pixelWidth / pixelHeight;
if (currentAspect < nativeAspect)
s = pixelWidth / nativeResolutionWidth;
else
s = pixelHeight / nativeResolutionHeight;
if (currentResolutionOverride.autoScaleMode == tk2dCameraResolutionOverride.AutoScaleMode.PixelPerfectFit)
{
if (s > 1.0f)
s = Mathf.Floor(s); // round number
else
s = Mathf.Pow(2, Mathf.Floor(Mathf.Log(s, 2))); // minimise only as power of two
}
scale.Set(s, s);
break;
case tk2dCameraResolutionOverride.AutoScaleMode.StretchToFit:
scale.Set(pixelWidth / nativeResolutionWidth, pixelHeight / nativeResolutionHeight);
break;
default:
case tk2dCameraResolutionOverride.AutoScaleMode.None:
//.........这里部分代码省略.........
开发者ID:jpann,项目名称:MissileDefense,代码行数:101,代码来源:tk2dCamera.cs
注:本文中的tk2dCamera类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论