本文整理汇总了C#中Transform类的典型用法代码示例。如果您正苦于以下问题:C# Transform类的具体用法?C# Transform怎么用?C# Transform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transform类属于命名空间,在下文中一共展示了Transform类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Awake
// Awake
void Awake()
{
myRigidbody = GetComponent<Rigidbody>();
myRigidbody.maxAngularVelocity = 25f;
myTransform = GetComponent<Transform>();
cameraTransform = Camera.main.GetComponent<Transform>();
}
开发者ID:ifty420,项目名称:Fuel-Truck-Eugene-2,代码行数:8,代码来源:BallMove.cs
示例2: OnCollisionWithEnemy
protected void OnCollisionWithEnemy(GameObject enemy, float power)
{
power *= WeaponPowerMiltiplier;
enemyTransform = enemy.transform;
enemyController = enemy.GetComponent<FightEnemyController>();
if (power < MinForceToHit)
return;
// Blood
newBloodParticle = Instantiate<GameObject>(BloodParticles);
newBloodParticle.transform.position = enemyTransform.position;
newBloodParticle.transform.up = (enemyTransform.position - selfTransform.position).normalized;
Destroy(newBloodParticle, 1);
// Do damage
enemyController.DoDamage(Mathf.Clamp(power, MinForceToHit, MaxForceToHit));
//print(WeaponTypeName + ": " + hitVelocityMagnitude.ToString());
// Damage Text
newDamageText = Instantiate<GameObject>(DamageText);
newDamageTextText = newDamageText.GetComponent<Text>();
newDamageTextText.rectTransform.SetParent(WorldCanvas, false);
newDamageTextText.rectTransform.position = enemyTransform.position + new Vector3(0f, 0.5f, 0f); ;
newDamageTextText.text = string.Format("{0}", power.ToString("F0"));
}
开发者ID:perfectdaemon,项目名称:ragdoll-arena,代码行数:26,代码来源:WeaponController.cs
示例3: AddChain
//add chain into chains list
public void AddChain(Transform chain)
{
//if chains list isn't created, create it
if(chains == null)
chains = new List<Transform>();
//if linerenderer isn't added, add it
if(lineRend == null)
{
lineRend = GetComponent<LineRenderer>();
if(!lineRend)
{
lineRend = gameObject.AddComponent<LineRenderer>();
lineRend.material = ropeMaterial;
}
}
chains.Add (chain); //add chain into chains list
//fill LineRenderer component's positions
lineRend.SetVertexCount (chains.Count);
lineRend.SetPosition (chains.Count - 1, chains[chains.Count - 1].position);
startChainCount = chains.Count;
}
开发者ID:diglungdig,项目名称:AquaSkiing,代码行数:27,代码来源:UseLineRenderer.cs
示例4: CrossToTarget
public static float CrossToTarget(Transform thisXform, Vector3 targetPos)
{
Vector3 nominalPos = thisXform.position;
Vector3 DirToTarget = (targetPos - nominalPos).normalized;
Vector3 ForwardDir = thisXform.forward.normalized;
return Vector3.Cross(ForwardDir, DirToTarget).y;
}
开发者ID:liliankasem,项目名称:DroneControl,代码行数:7,代码来源:GeometryClass.cs
示例5: DrawLayoutOutline
void DrawLayoutOutline(Transform t) {
var layout = t.GetComponent<tk2dUILayout>();
if (layout != null) {
Vector3[] p = new Vector3[] {
new Vector3(layout.bMin.x, layout.bMin.y, 0.0f),
new Vector3(layout.bMax.x, layout.bMin.y, 0.0f),
new Vector3(layout.bMax.x, layout.bMax.y, 0.0f),
new Vector3(layout.bMin.x, layout.bMax.y, 0.0f),
new Vector3(layout.bMin.x, layout.bMin.y, 0.0f),
};
for (int i = 0; i < p.Length; ++i) p[i] = t.TransformPoint(p[i]);
Handles.color = Color.magenta;
Handles.DrawPolyLine(p);
var sizer = t.GetComponent<tk2dUILayoutContainerSizer>();
if (sizer != null) {
Handles.color = Color.cyan;
float arrowSize = 0.3f * HandleUtility.GetHandleSize(p[0]);
if (sizer.horizontal) {
Handles.ArrowCap(0, (p[0] + p[3]) * 0.5f, Quaternion.LookRotation(p[1] - p[0]), arrowSize);
Handles.ArrowCap(0, (p[1] + p[2]) * 0.5f, Quaternion.LookRotation(p[0] - p[1]), arrowSize);
} else {
Handles.ArrowCap(0, (p[0] + p[1]) * 0.5f, Quaternion.LookRotation(p[3] - p[0]), arrowSize);
Handles.ArrowCap(0, (p[2] + p[3]) * 0.5f, Quaternion.LookRotation(p[0] - p[3]), arrowSize);
}
}
}
for (int i = 0; i < t.childCount; ++i)
DrawLayoutOutline(t.GetChild(i));
}
开发者ID:AtwoodDeng,项目名称:GGJ2015,代码行数:31,代码来源:tk2dUILayoutEditor.cs
示例6: Shot
public override void Shot (Vector3 shotOrigin, GameObject target, Transform cannonTransform)
{
//if(WeaponReady)
{
WeaponReady = false;
Vector3 shotDirection = cannonTransform.forward;
// Note: In a real project, you must not instante many objects a runtime, instead, you may consider creating a shoot pool.
Rigidbody newBullet = Instantiate(bullet,shotOrigin,cannonTransform.rotation) as Rigidbody;
newBullet.AddForce(shotForce*shotDirection);
if(shotSound != null && shotAudioSource != null)
shotAudioSource.PlayOneShot(shotSound);
if(weaponParticleSystem != null)
weaponParticleSystem.Play();
StartCoroutine(LightFlash());
// Reset timmer
timeCounter = 0f;
}
}
开发者ID:EvilAbyss,项目名称:Wulfram,代码行数:25,代码来源:ExampleWeapon.cs
示例7: CalculateAbsoluteWidgetBounds
/// <summary>
/// Calculate the combined bounds of all widgets attached to the specified game object or its children (in world space).
/// </summary>
public static Bounds CalculateAbsoluteWidgetBounds(Transform trans)
{
UIWidget[] widgets = trans.GetComponentsInChildren<UIWidget>() as UIWidget[];
Bounds b = new Bounds(trans.transform.position, Vector3.zero);
bool first = true;
foreach (UIWidget w in widgets)
{
Vector2 size = w.relativeSize;
Vector2 offset = w.pivotOffset;
float x = (offset.x + 0.5f) * size.x;
float y = (offset.y - 0.5f) * size.y;
size *= 0.5f;
Transform wt = w.cachedTransform;
Vector3 v0 = wt.TransformPoint(new Vector3(x - size.x, y - size.y, 0f));
// 'Bounds' can never start off with nothing, apparently, and including the origin point is wrong.
if (first)
{
first = false;
b = new Bounds(v0, Vector3.zero);
}
else
{
b.Encapsulate(v0);
}
b.Encapsulate(wt.TransformPoint(new Vector3(x - size.x, y + size.y, 0f)));
b.Encapsulate(wt.TransformPoint(new Vector3(x + size.x, y - size.y, 0f)));
b.Encapsulate(wt.TransformPoint(new Vector3(x + size.x, y + size.y, 0f)));
}
return b;
}
开发者ID:quiker,项目名称:hexagon,代码行数:38,代码来源:NGUIMath.cs
示例8: TryGiveItem
/// <summary>
/// tries to award an item to a recipient by transform, item type
/// and amount
/// </summary>
public static bool TryGiveItem(Transform recipient, vp_ItemType itemType, int amount)
{
if (recipient == null)
{
Debug.LogError("Error (" + Instance + ") Recipient was null.");
return false;
}
vp_Inventory inventory;
if (!m_RecipientInventories.TryGetValue(recipient, out inventory))
{
inventory = vp_TargetEventReturn<vp_Inventory>.SendUpwards(recipient, "GetInventory");
m_RecipientInventories.Add(recipient, inventory);
}
if (inventory == null)
{
Debug.LogError("Error (" + Instance + ") Failed to find an enabled inventory on '" + recipient + "'.");
return false;
}
if (TryMatchExistingItem(inventory, recipient, itemType, amount))
return true;
return TryGiveItemAsNew(recipient, itemType, amount);
}
开发者ID:Bakiet,项目名称:EvilAwakening,代码行数:32,代码来源:vp_MPItemList.cs
示例9: StateAgro
public StateAgro(NavMeshAgent _agent, Vector3 _point, Transform _transform, ref StateSet _set)
{
set = _set;
transform = _transform;
agent = _agent;
point = _point;
}
开发者ID:OSW-team,项目名称:Project-4,代码行数:7,代码来源:StateMachine.cs
示例10: Start
// Use this for initialization
void Start()
{
player = PlayerController.MyTransform;
candig = false;
diggableItem.SetActive(false);
digtime = 0f;
}
开发者ID:stuarrt,项目名称:StarCrossing,代码行数:8,代码来源:DigMarker.cs
示例11: AddChildren
private void AddChildren(Transform parent, List<Transform> list)
{
list.Add (parent);
foreach (Transform t in parent) {
AddChildren (t, list);
}
}
开发者ID:kahojon,项目名称:NewApplication,代码行数:7,代码来源:Ragdoll.cs
示例12: Start
// Use this for initialization
void Start()
{
//make a reference with the transform component
this._transform = gameObject.GetComponent<Transform>();
this.Reset();
}
开发者ID:dpandya76,项目名称:2D-Shooter-Horizontal,代码行数:8,代码来源:SkyController.cs
示例13: HideObject
// Reparents to a new object and deactivates that object (this allows
// us to call SetActive in OnDeviceConnected independently.
private void HideObject(Transform t, string name)
{
var hidden = new GameObject(name).transform;
hidden.parent = t.parent;
t.parent = hidden;
hidden.gameObject.SetActive(false);
}
开发者ID:paganini24,项目名称:ViveUGUIModule,代码行数:9,代码来源:SteamVR_ControllerManager.cs
示例14: OnDropStop
public override void OnDropStop(Transform objectBellow)
{
base.OnDropStop (objectBellow);
if (!objectBellow.gameObject.layer.Equals (LayerMask.NameToLayer ("Crates")))
Open ();
}
开发者ID:BandicootUnity,项目名称:Crash-Bandicoot-The-Return-Project-Team,代码行数:7,代码来源:Checkbox.cs
示例15: SetTarget
public void SetTarget(GameObject NewTarget)
{
Target = NewTarget;
Reset = false;
EnemyTransform = Target.GetComponent<Transform>();
}
开发者ID:bjsvochak,项目名称:hof16,代码行数:7,代码来源:AutoTurretLock.cs
示例16: handleHierarchy
private void handleHierarchy(Transform root, Dictionary<string,bool> presenceByName, Dictionary<string,Transform> originalsByName)
{
List<Transform> allChildren = new List<Transform>( presenceByName.Count );
concatenateHierarchy(root, allChildren);
foreach(Transform t in allChildren)
{
GameObject go = t.gameObject;
//bool thisIsTheSkinnedMeshRenderer = go.renderer != null && go.renderer is SkinnedMeshRenderer;
string key = t.name;
bool shouldBePresent = presenceByName.ContainsKey(key) ? presenceByName[key] : false;
shouldBePresent &= originalsByName[key].gameObject.activeSelf;
go.SetActive( shouldBePresent ); // || thisIsTheSkinnedMeshRenderer;
}
foreach(Transform t in allChildren)
{
string key = t.name;
if(originalsByName.ContainsKey(key))
{
Transform original = originalsByName[key];
t.localPosition = original.localPosition;
t.localRotation = original.localRotation;
t.localScale = original.localScale;
}
}
}
开发者ID:VirsixInc,项目名称:CatapultKing,代码行数:35,代码来源:HierarchyHandling.cs
示例17: Init
public void Init(Transform canvasTransform, float killedUnitsCount, float timePassed)
{
transform.SetParent(canvasTransform);
(transform as RectTransform).anchoredPosition = Vector3.zero;
_killedUnitsCount.text = string.Format(Constants.Common.GameEndedText, killedUnitsCount, timePassed);
}
开发者ID:darkcheg,项目名称:RikiTest,代码行数:7,代码来源:UIView.cs
示例18: Start
// Use this for initialization
void Start()
{
Mytrans = GetComponent<Transform>();
InitFacing = Mytrans.forward.normalized;
Reset = true;
RotateSpeed = 0.8f;
}
开发者ID:bjsvochak,项目名称:hof16,代码行数:8,代码来源:AutoTurretLock.cs
示例19: Awake
private void Awake()
{
button = transform.FindChild("Button");
thebase = transform.FindChild("Base");
startScale = button.localScale;
targetScale = thebase.localScale;
}
开发者ID:EJBQ,项目名称:Bae-Zeus-X,代码行数:7,代码来源:LongPress_Button.cs
示例20: Start
void Start()
{
_t = transform;
_animator = GetComponent<Animator>();
_controller = GetComponent<CharacterController>();
_rigidbody = GetComponent<Rigidbody>();
}
开发者ID:choang05,项目名称:Puzzle-2,代码行数:7,代码来源:SrpgcMouseMovementController.cs
注:本文中的Transform类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论