本文整理汇总了C#中UnityEngine.Transform类的典型用法代码示例。如果您正苦于以下问题:C# Transform类的具体用法?C# Transform怎么用?C# Transform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transform类属于UnityEngine命名空间,在下文中一共展示了Transform类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
public static GameObject Create(GameObject prefab, Vector3 pos, Quaternion rot, Transform parent)
{
if (parent == null) return Create(prefab, pos, rot);
prefab.AddOrGetComponent<EarlyParentSetter>().Init(parent);
return UnityEngine.Object.Instantiate(prefab, pos, rot) as GameObject;
}
开发者ID:Gege00,项目名称:spacepuppy-unity-framework,代码行数:7,代码来源:PrefabUtil.cs
示例2: CalculateAnchorSnapValues
internal static void CalculateAnchorSnapValues(Transform parentSpace, Transform self, RectTransform gui, int minmaxX, int minmaxY)
{
for (int mainAxis = 0; mainAxis < 2; ++mainAxis)
{
RectTransformSnapping.s_SnapGuides[mainAxis].Clear();
parentSpace.GetComponent<RectTransform>().GetWorldCorners(RectTransformSnapping.s_Corners);
for (int index = 0; index < RectTransformSnapping.kSidesAndMiddle.Length; ++index)
{
float alongMainAxis = RectTransformSnapping.kSidesAndMiddle[index];
RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(alongMainAxis, new Vector3[2]
{
RectTransformSnapping.GetInterpolatedCorner(RectTransformSnapping.s_Corners, mainAxis, alongMainAxis, 0.0f),
RectTransformSnapping.GetInterpolatedCorner(RectTransformSnapping.s_Corners, mainAxis, alongMainAxis, 1f)
}));
}
foreach (Transform transform in parentSpace)
{
if (!((Object) transform == (Object) self))
{
RectTransform component = transform.GetComponent<RectTransform>();
if ((bool) ((Object) component))
{
RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(component.anchorMin[mainAxis], new Vector3[0]));
RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(component.anchorMax[mainAxis], new Vector3[0]));
}
}
}
int num = mainAxis != 0 ? minmaxY : minmaxX;
if (num == 0)
RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(gui.anchorMax[mainAxis], new Vector3[0]));
if (num == 1)
RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(gui.anchorMin[mainAxis], new Vector3[0]));
}
}
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:34,代码来源:RectTransformSnapping.cs
示例3: MapData
public MapData(Transform parent, string mapName, int width, int height)
{
this.ParentTransform = parent;
this.Name = mapName;
this.Width = width;
this.Height = height;
}
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:7,代码来源:MapData.cs
示例4: WheelDummy
/// <summary>
/// Initializes a new instance of the <see cref="Trackar.WheelDummy"/> class.
/// </summary>
/// <param name="col">Col.</param>
/// <param name="joint">Joint.</param>
/// <param name="model">Model.</param>
/// <param name="config">WheelDummyConfigContainer.</param>
public WheelDummy(WheelCollider col, Transform joint, GameObject model, WheelDummyConfigContainer config)
{
if (col == null)
{
Debuggar.Error ("WheelDummy: Attempted spawn with null WheelCollider");
col = new WheelCollider ();
}
if(joint == null)
{
Debuggar.Error ("WheelDummy: Attempted spawn with null Joint");
joint = new GameObject ().transform; // lol gg unity
}
if(model == null)
{
Debuggar.Error ("WheelDummy: Attempted spawn with null Model");
model = new GameObject ();
}
if(config == null)
{
Debuggar.Error ("WheelDummy: Attempted spawn with null WheelDummyConfigContainer");
config = new WheelDummyConfigContainer ();
}
Collider = col;
Joint = joint;
WheelModel = model;
Susp = config.SuspConfig;
Collider.enabled = true;
Collider.brakeTorque = config.RollingResistance;
Debuggar.Message ("WheelDummy: brakeTorque is " + Collider.brakeTorque.ToString () + " RollingResistance is " + config.RollingResistance.ToString ());
Debuggar.Message ("WheelDummy: Spawned");
}
开发者ID:brunodisilva,项目名称:trackar,代码行数:41,代码来源:WheelDummy.cs
示例5: DoAction
public void DoAction(SetQuestStateAction action, Transform actor)
{
if ((action != null) && !string.IsNullOrEmpty(action.questName)) {
QuestLog.SetQuestState(action.questName, action.questState);
if (!string.IsNullOrEmpty(action.alertMessage)) DialogueManager.ShowAlert(action.alertMessage);
}
}
开发者ID:farreltr,项目名称:OneLastSunset,代码行数:7,代码来源:SetQuestStateOnDialogueEvent.cs
示例6: TryActions
private void TryActions(SetQuestStateAction[] actions, Transform actor)
{
if (actions == null) return;
foreach (SetQuestStateAction action in actions) {
if (action != null && action.condition != null && action.condition.IsTrue(actor)) DoAction(action, actor);
}
}
开发者ID:farreltr,项目名称:OneLastSunset,代码行数:7,代码来源:SetQuestStateOnDialogueEvent.cs
示例7: ActiveRecursively
public static void ActiveRecursively(Transform obj, bool active)
{
foreach (Transform child in obj) {
InfiniteRunnerStarterPackUtility.ActiveRecursively(child, active);
}
obj.gameObject.SetActive(active);
}
开发者ID:Maareks,项目名称:Endless-Cat,代码行数:7,代码来源:InfiniteRunnerStarterPackUtility.cs
示例8: Update
public override Status Update () {
// Get the point transform
if (m_PointTransform == null || m_PointTransform.gameObject != point.Value)
m_PointTransform = point.Value != null ? point.Value.transform : null;
// Validate members
if (m_PointTransform == null)
return Status.Error;
// OverlapPoint
Collider2D collider2D = Physics2D.OverlapPoint(m_PointTransform.position, layers);
// Is there a collider2D inside the rectangle?
if (collider2D != null) {
// Store result
storeGameObject.Value = collider2D.gameObject;
// Tick child?
if (child != null) {
child.OnTick();
return child.status;
}
else
return Status.Success;
}
else {
// Store result
storeGameObject.Value = null;
return Status.Failure;
}
}
开发者ID:xclouder,项目名称:godbattle,代码行数:31,代码来源:OverlapPoint.cs
示例9: WidgetData
public WidgetData(string layer, string name, Transform widget, string type)
{
this.layerName = layer;
this.widgetName = name;
this.widgetObject = widget;
this.widgetType = type;
}
开发者ID:robertvoigt030,项目名称:ugb-source,代码行数:7,代码来源:WidgetData.cs
示例10: SetLookAt
public void SetLookAt(Transform lookAtObject, LookAtAxis axis)
{
if (m_transformComponent == null)
m_transformComponent = this.GetComponent<Transform>();
if (m_transformComponent != null)
{
Vector3 currentLookAtAxis = Vector3.zero;
switch (axis)
{
case LookAtAxis.Up:
currentLookAtAxis = m_transformComponent.up;
break;
case LookAtAxis.Down:
currentLookAtAxis = -m_transformComponent.up;
break;
case LookAtAxis.Right:
currentLookAtAxis = m_transformComponent.right;
break;
case LookAtAxis.Left:
currentLookAtAxis = -m_transformComponent.right;
break;
case LookAtAxis.Forward:
currentLookAtAxis = m_transformComponent.forward;
break;
}
m_transformComponent.LookAt(LookAtObject, currentLookAtAxis);
}
}
开发者ID:DevMikaelNilsson,项目名称:mnUtilities,代码行数:30,代码来源:LookAt.cs
示例11: CactEyeCamera
/*
* Constructor
* Input: The owning part's transform.
* Purpose: This constructor will start up the owning part's camera object. The idea behind this
* was to allow for multiple telescopes on the same craft.
*/
public CactEyeCamera(Transform Position)
{
this.CameraTransform = Position;
CameraWidth = (int)(Screen.width*0.4f);
CameraHeight = (int)(Screen.height*0.4f);
ScopeRenderTexture = new RenderTexture(CameraWidth, CameraHeight, 24);
ScopeRenderTexture.Create();
FullResolutionTexture = new RenderTexture(Screen.width, Screen.height, 24);
FullResolutionTexture.Create();
ScopeTexture2D = new Texture2D(CameraWidth, CameraHeight);
FullTexture2D = new Texture2D(Screen.width, Screen.height);
CameraSetup(0, "GalaxyCamera"); //As of KSP 1.0, the GalaxyCamera object was added. Thanks to MOARDv for figuring this one out.
CameraSetup(1, "Camera ScaledSpace");
CameraSetup(2, "Camera 01");
CameraSetup(3, "Camera 00");
CameraSetup(4, "Camera VE Underlay");
CameraSetup(5, "Camera VE Overlay");
skyboxRenderers = (from Renderer r in (FindObjectsOfType(typeof(Renderer)) as IEnumerable<Renderer>) where (r.name == "XP" || r.name == "XN" || r.name == "YP" || r.name == "YN" || r.name == "ZP" || r.name == "ZN") select r).ToArray<Renderer>();
if (skyboxRenderers == null)
{
Debug.Log("CactEye 2: Logical Error: skyboxRenderers is null!");
}
scaledSpaceFaders = FindObjectsOfType(typeof(ScaledSpaceFader)) as ScaledSpaceFader[];
if (scaledSpaceFaders == null)
{
Debug.Log("CactEye 2: Logical Error: scaledSpaceFaders is null!");
}
}
开发者ID:belug23,项目名称:CactEye-2,代码行数:41,代码来源:CactEyeCamera.cs
示例12: ApplyTransform
/// <inheritdoc />
public void ApplyTransform(Transform target)
{
if (DeltaPosition != Vector3.zero) target.position += DeltaPosition;
if (!Mathf.Approximately(DeltaRotation, 0f))
target.rotation = Quaternion.Euler(0, 0, DeltaRotation)*target.rotation;
if (!Mathf.Approximately(DeltaScale, 1f)) target.localScale *= DeltaScale;
}
开发者ID:AhoyGames,项目名称:TouchScript,代码行数:8,代码来源:ScreenTransformGesture.cs
示例13: CaptureTransform
void CaptureTransform(Transform transform, string path, AnimationClip clip)
{
path += transform.name;
//Debug.Log(path);
if (position.Value)
{
CapturePosition(transform, path, clip);
}
if (rotation.Value)
{
CaptureRotation(transform, path, clip);
}
if (scale.Value)
{
CaptureScale(transform, path, clip);
}
foreach (Transform child in transform)
{
CaptureTransform(child, path + "/", clip);
}
}
开发者ID:DIGM680,项目名称:NarrativePlatformer,代码行数:26,代码来源:CapturePoseAsAnimationClip.cs
示例14: ExportAnimations
private static void ExportAnimations(Transform transform, BabylonIAnimatable animatable)
{
var animator = transform.gameObject.GetComponent<Animator>();
if (animator != null)
{
AnimatorController ac = animator.runtimeAnimatorController as AnimatorController;
if (ac == null)
{
return;
}
var layer = ac.layers[0];
if (layer == null)
{
return;
}
AnimatorStateMachine sm = layer.stateMachine;
if (sm.states.Length > 0)
{
var state = sm.states[0].state; // We only support the first one
AnimationClip clip = state.motion as AnimationClip;
if (clip != null)
{
ExportAnimationClip(clip, true, animatable);
}
}
}
else
{
var animation = transform.gameObject.GetComponent<Animation>();
if (animation != null && animation.clip != null)
{
ExportAnimationClip(animation.clip, animation.playAutomatically, animatable);
}
}
}
开发者ID:lukasdruzba,项目名称:Babylon.js,代码行数:35,代码来源:SceneBuilder.Animations.cs
示例15: Update
public override Status Update () {
// Get the transform
if (m_Transform == null || m_Transform.gameObject != gameObject.Value)
m_Transform = gameObject.Value != null ? gameObject.Value.transform : null;
// Validate members?
if (m_Transform == null)
return Status.Error;
// Get the desiredTranslation
Vector3 desiredTranslation = !translation.isNone ? translation.Value : Vector3.zero;
// Override values?
if (!x.isNone) desiredTranslation.x = x.Value;
if (!y.isNone) desiredTranslation.y = y.Value;
if (!z.isNone) desiredTranslation.z = z.Value;
// Translate per second?
if (perSecond)
m_Transform.Translate(desiredTranslation * this.owner.deltaTime, relativeTo);
else
m_Transform.Translate(desiredTranslation, relativeTo);
return Status.Success;
}
开发者ID:xclouder,项目名称:godbattle,代码行数:25,代码来源:Translate.cs
示例16: AnimatedNode
public AnimatedNode(AttachNode node, Transform node_transform, Part part)
{
this.node = node;
this.part = part;
nT = node_transform;
pT = part.partTransform;
}
开发者ID:kevin-ye,项目名称:hangar,代码行数:7,代码来源:AnimatedNode.cs
示例17: SetStatsValue
private void SetStatsValue(Transform t, float value)
{
RectTransform r = t.GetComponent<RectTransform>();
var size = r.rect.size.x - r.offsetMax.x; // + car value -
var val = size - ((size / 10) * value);
r.offsetMax = new Vector2(-val, r.offsetMax.y);
}
开发者ID:CanPayU,项目名称:SuperSwungBall,代码行数:7,代码来源:ChallengeController.cs
示例18: WaterTileBeingRendered
public void WaterTileBeingRendered(Transform tr, Camera currentCam)
{
if (currentCam && edgeBlend)
{
currentCam.depthTextureMode |= DepthTextureMode.Depth;
}
}
开发者ID:CenzyGames,项目名称:Save-your-date-new,代码行数:7,代码来源:WaterBase.cs
示例19: Update
public override Status Update () {
// Get the transform1
if (m_Transform1 == null || m_Transform1.gameObject != gameObject1.Value)
m_Transform1 = gameObject1.Value != null ? gameObject1.Value.transform : null;
// Get the transform2
if (m_Transform2 == null || m_Transform2.gameObject != gameObject2.Value)
m_Transform2 = gameObject2.Value != null ? gameObject2.Value.transform : null;
// Validate members
if (m_Transform1 == null || m_Transform2 == null)
return Status.Error;
// Store distance
if (relativeTo == Space.World)
storeDistance.Value = m_Transform1.position - m_Transform2.position;
else
storeDistance.Value = m_Transform1.localPosition - m_Transform2.localPosition;
storeX.Value = storeDistance.Value.x;
storeY.Value = storeDistance.Value.y;
storeZ.Value = storeDistance.Value.z;
return Status.Success;
}
开发者ID:xclouder,项目名称:godbattle,代码行数:25,代码来源:GetDistance.cs
示例20: GetDirectParticleSystemChildrenRecursive
private static void GetDirectParticleSystemChildrenRecursive(Transform transform, List<ParticleSystem> particleSystems)
{
IEnumerator enumerator = transform.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Transform current = (Transform) enumerator.Current;
ParticleSystem component = current.gameObject.GetComponent<ParticleSystem>();
if (component != null)
{
particleSystems.Add(component);
GetDirectParticleSystemChildrenRecursive(current, particleSystems);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable == null)
{
}
disposable.Dispose();
}
}
开发者ID:randomize,项目名称:VimConfig,代码行数:25,代码来源:ParticleSystem.cs
注:本文中的UnityEngine.Transform类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论