本文整理汇总了C#中UnityEngine.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# UnityEngine.GetComponent方法的具体用法?C# UnityEngine.GetComponent怎么用?C# UnityEngine.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine
的用法示例。
在下文中一共展示了UnityEngine.GetComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createDuplication
public void createDuplication(UnityEngine.GameObject Item)
{
Item item = Item.GetComponent<ItemOnObject>().item;
UnityEngine.GameObject duplication = UnityEngine.GameObject.FindGameObjectWithTag("MainInventory").GetComponent<Inventory>().addItemToInventory(item.itemID, item.itemValue);
duplication.transform.parent.parent.parent.GetComponent<Inventory>().stackableSettings();
Item.GetComponent<ConsumeItem>().duplication = duplication;
duplication.GetComponent<ConsumeItem>().duplication = Item;
}
示例2: HandleCustomProperties
public void HandleCustomProperties(UnityEngine.GameObject gameObject,
IDictionary<string, string> props)
{
// Simply add a component to our GameObject
if (props.ContainsKey ("PrefabPath")) {
string path = props["PrefabPath"];
UnityEngine.Object spawn =
AssetDatabase.LoadAssetAtPath(path, typeof(GameObject));
if (spawn != null)
{
GameObject spawnInstance =
(GameObject)GameObject.Instantiate(spawn);
spawnInstance.name = spawn.name;
// Use the position of the game object we're attached to
spawnInstance.transform.parent = gameObject.transform;
spawnInstance.transform.localPosition = Vector3.zero;
gameObject.transform.localScale = Vector3.one * 100;
}
}
if (props.ContainsKey ("Platform")) {
gameObject.GetComponent<Collider2D>().usedByEffector = true;
gameObject.AddComponent<PlatformEffector2D>().surfaceArc = 170f;
}
if(props.ContainsKey("ColliderMaterial"))
{
foreach(Collider2D collider in gameObject.GetComponentsInChildren<Collider2D>())
{
string path = props["ColliderMaterial"];
collider.sharedMaterial = (PhysicsMaterial2D)AssetDatabase.LoadAssetAtPath(path, typeof(PhysicsMaterial2D));
}
}
}
示例3: DynamicSequenceOpen
public static uint DynamicSequenceOpen(UnityEngine.GameObject in_gameObjectID, uint in_uFlags, AkCallbackManager.EventCallback in_pfnCallback, object in_pCookie) {
uint tempin_gameObjectID;
if ( in_gameObjectID != null )
{
tempin_gameObjectID = (uint)in_gameObjectID.GetInstanceID();
// Note: if AkGameObjectTracker is already attached, the following code will be bypassed.
if (in_gameObjectID.GetComponent<AkGameObject>() == null)
{
in_gameObjectID.AddComponent<AkGameObject>();
}
}
else
{
tempin_gameObjectID = unchecked((uint)-1);
}
in_pCookie = new AkCallbackManager.EventCallbackPackage(in_pfnCallback, in_pCookie);
{
uint ret = AkSoundEnginePINVOKE.CSharp_DynamicSequenceOpen__SWIG_1(tempin_gameObjectID, in_uFlags, (IntPtr)0, (IntPtr)in_pCookie.GetHashCode());
return ret;
}
}
示例4: TagApplies
public override bool TagApplies(UnityEngine.GameObject gameObject, AudioManager.ListenerInfo info)
{
SettingsManager.Options ModOptions = gameObject.GetComponent<SettingsManager>().ModOptions;
int finalHappiness = (int)Singleton<DistrictManager>.instance.m_districts.m_buffer[0].m_finalHappiness;
return (finalHappiness < ModOptions.MoodDependentMusic_MoodThreshold);
}
示例5: Cast
public override void Cast (UnityEngine.GameObject primaryTarget)
{
var wizz = primaryTarget.GetComponent<Wizard> ();
if (wizz) {
wizz.weapon.Enchant (this, Color.red, lifetime);
UIStatusManager.Instance.AddBuff (DatabaseInstance.Icon, lifetime, "Deals fire damage on melee attacks");
}
Destroy (this.gameObject, lifetime);
}
示例6: HandleCustomProperties
public void HandleCustomProperties(UnityEngine.GameObject gameObject,
IDictionary<string, string> props)
{
if (props.ContainsKey("TargetDoor")) {
gameObject.AddComponent<MurderMystery.DoorwayScript>();
gameObject.GetComponent<MurderMystery.DoorwayScript>().targetDoor = props["TargetDoor"];
}
if (props.ContainsKey("Room")) {
gameObject.AddComponent<MurderMystery.ContainerScript>();
gameObject.GetComponent<MurderMystery.ContainerScript>().roomName = props["Room"];
gameObject.tag = "Container";
gameObject.layer = LayerMask.NameToLayer("Containers");
}
if (props.ContainsKey("Ceiling")) {
gameObject.layer = LayerMask.NameToLayer("Ceilings");
gameObject.tag = "Ceiling";
Ceiling ceiling = gameObject.AddComponent<Ceiling>();
ceiling.roomName = props["Ceiling"];
}
}
示例7: SetAnimatorController
private void SetAnimatorController(UnityEngine.UI.Image image, Transform speaker, ref Animator animator) {
if (speaker == null || image == null) return;
if (animator == null) animator = image.GetComponent<Animator>();
if (animator == null) animator = image.gameObject.AddComponent<Animator>();
if (!animatedPortraits.ContainsKey(speaker)) {
var animatedPortrait = (speaker != null) ? speaker.GetComponentInChildren<AnimatedPortrait>() : null;
animatedPortraits.Add(speaker, animatedPortrait);
}
if (animatedPortraits[speaker] != null) {
var animatorController = animatedPortraits[speaker].animatorController;
if (animator.runtimeAnimatorController != animatorController) {
animator.runtimeAnimatorController = animatorController;
}
}
}
示例8: DynamicSequenceOpen
public static uint DynamicSequenceOpen(UnityEngine.GameObject in_gameObjectID, uint in_uFlags, AkCallbackManager.EventCallback in_pfnCallback, object in_pCookie) {
uint tempin_gameObjectID;
if ( in_gameObjectID != null )
{
tempin_gameObjectID = (uint)in_gameObjectID.GetInstanceID();
// Note: if AkGameObjectTracker is already attached, the following code will be bypassed.
if (in_gameObjectID.GetComponent<AkGameObject>() == null)
{
in_gameObjectID.AddComponent<AkGameObject>();
// Note: We have missed AkGameObject.Awake() of this run to register.
// So we take over its work by inlining it here.
AkSoundEngine.RegisterGameObj(in_gameObjectID, in_gameObjectID.name);
//Set the original position
AkSoundEngine.SetObjectPosition(
in_gameObjectID,
in_gameObjectID.transform.position.x,
in_gameObjectID.transform.position.y,
in_gameObjectID.transform.position.z,
in_gameObjectID.transform.forward.x,
in_gameObjectID.transform.forward.y,
in_gameObjectID.transform.forward.z
);
}
}
else
{
tempin_gameObjectID = unchecked((uint)-1);
}
in_pCookie = new AkCallbackManager.EventCallbackPackage(in_pfnCallback, in_pCookie);
{
uint ret = AkSoundEnginePINVOKE.CSharp_DynamicSequenceOpen__SWIG_1(tempin_gameObjectID, in_uFlags, (IntPtr)0, (IntPtr)in_pCookie.GetHashCode());
return ret;
}
}
示例9: ApplyDamageTo
// Applies damage to specified GameObject
public override void ApplyDamageTo(UnityEngine.GameObject target)
{
// if the target object is equal to
// the source object, return
if (target == source)
return;
// Check the targets tag
switch (target.tag)
{
// if it is the ship
case "Ship":
// Get the ship and the shield components
var ship = target.GetComponent<Ship>();
var shield = ship.Shield;
// if the shield exists
// Set damage to the CurrentShields
if (shield != null && shield.CurrentShields >= 0)
{
Debug.Log("Hit Shield");
shield.CurrentShields -= damage;
}
// if the shield does not exist
// Set damage to the ship
else
{
Debug.Log("Hit Ship");
ship.CurrentHP -= damage;
}
break;
// deafult case
default:
break;
}
// Destroys object
Destroy(gameObject);
}
示例10: GetPlayingIDsFromGameObject
public static AKRESULT GetPlayingIDsFromGameObject(UnityEngine.GameObject in_GameObjId, ref uint io_ruNumIDs, uint[] out_aPlayingIDs) {
uint tempin_GameObjId;
if ( in_GameObjId != null )
{
tempin_GameObjId = (uint)in_GameObjId.GetInstanceID();
// Note: if AkGameObjectTracker is already attached, the following code will be bypassed.
if (in_GameObjId.GetComponent<AkGameObject>() == null)
{
in_GameObjId.AddComponent<AkGameObject>();
// Note: We have missed AkGameObject.Awake() of this run to register.
// So we take over its work by inlining it here.
AkSoundEngine.RegisterGameObj(in_GameObjId, in_GameObjId.name);
//Set the original position
AkSoundEngine.SetObjectPosition(
in_GameObjId,
in_GameObjId.transform.position.x,
in_GameObjId.transform.position.y,
in_GameObjId.transform.position.z,
in_GameObjId.transform.forward.x,
in_GameObjId.transform.forward.y,
in_GameObjId.transform.forward.z
);
}
}
else
{
tempin_GameObjId = unchecked((uint)-1);
}
{
AKRESULT ret = (AKRESULT)AkSoundEnginePINVOKE.CSharp_GetPlayingIDsFromGameObject(tempin_GameObjId, ref io_ruNumIDs, out_aPlayingIDs);
return ret;
}
}
示例11: GetGameObjectAuxSendValues
public static AKRESULT GetGameObjectAuxSendValues(UnityEngine.GameObject in_gameObjectID, AkAuxSendArray out_paAuxSendValues, ref uint io_ruNumSendValues) {
uint tempin_gameObjectID;
if ( in_gameObjectID != null )
{
tempin_gameObjectID = (uint)in_gameObjectID.GetInstanceID();
// Note: if AkGameObjectTracker is already attached, the following code will be bypassed.
if (in_gameObjectID.GetComponent<AkGameObject>() == null)
{
in_gameObjectID.AddComponent<AkGameObject>();
// Note: We have missed AkGameObject.Awake() of this run to register.
// So we take over its work by inlining it here.
AkSoundEngine.RegisterGameObj(in_gameObjectID, in_gameObjectID.name);
//Set the original position
AkSoundEngine.SetObjectPosition(
in_gameObjectID,
in_gameObjectID.transform.position.x,
in_gameObjectID.transform.position.y,
in_gameObjectID.transform.position.z,
in_gameObjectID.transform.forward.x,
in_gameObjectID.transform.forward.y,
in_gameObjectID.transform.forward.z
);
}
}
else
{
tempin_gameObjectID = unchecked((uint)-1);
}
{
AKRESULT ret = (AKRESULT)AkSoundEnginePINVOKE.CSharp_GetGameObjectAuxSendValues(tempin_gameObjectID, out_paAuxSendValues.m_Buffer, ref io_ruNumSendValues);
return ret;
}
}
示例12: GetSwitch
public static AKRESULT GetSwitch(string in_pstrSwitchGroupName, UnityEngine.GameObject in_GameObj, out uint out_rSwitchState) {
uint tempin_GameObj;
if ( in_GameObj != null )
{
tempin_GameObj = (uint)in_GameObj.GetInstanceID();
// Note: if AkGameObjectTracker is already attached, the following code will be bypassed.
if (in_GameObj.GetComponent<AkGameObject>() == null)
{
in_GameObj.AddComponent<AkGameObject>();
// Note: We have missed AkGameObject.Awake() of this run to register.
// So we take over its work by inlining it here.
AkSoundEngine.RegisterGameObj(in_GameObj, in_GameObj.name);
//Set the original position
AkSoundEngine.SetObjectPosition(
in_GameObj,
in_GameObj.transform.position.x,
in_GameObj.transform.position.y,
in_GameObj.transform.position.z,
in_GameObj.transform.forward.x,
in_GameObj.transform.forward.y,
in_GameObj.transform.forward.z
);
}
}
else
{
tempin_GameObj = unchecked((uint)-1);
}
{
AKRESULT ret = (AKRESULT)AkSoundEnginePINVOKE.CSharp_GetSwitch__SWIG_1(in_pstrSwitchGroupName, tempin_GameObj, out out_rSwitchState);
return ret;
}
}
示例13: ResetRTPCValue
public static AKRESULT ResetRTPCValue(string in_pszRtpcName, UnityEngine.GameObject in_gameObjectID, int in_uValueChangeDuration, AkCurveInterpolation in_eFadeCurve) {
uint tempin_gameObjectID;
if ( in_gameObjectID != null )
{
tempin_gameObjectID = (uint)in_gameObjectID.GetInstanceID();
// Note: if AkGameObjectTracker is already attached, the following code will be bypassed.
if (in_gameObjectID.GetComponent<AkGameObject>() == null)
{
in_gameObjectID.AddComponent<AkGameObject>();
// Note: We have missed AkGameObject.Awake() of this run to register.
// So we take over its work by inlining it here.
AkSoundEngine.RegisterGameObj(in_gameObjectID, in_gameObjectID.name);
//Set the original position
AkSoundEngine.SetObjectPosition(
in_gameObjectID,
in_gameObjectID.transform.position.x,
in_gameObjectID.transform.position.y,
in_gameObjectID.transform.position.z,
in_gameObjectID.transform.forward.x,
in_gameObjectID.transform.forward.y,
in_gameObjectID.transform.forward.z
);
}
}
else
{
tempin_gameObjectID = unchecked((uint)-1);
}
{
AKRESULT ret = (AKRESULT)AkSoundEnginePINVOKE.CSharp_ResetRTPCValue__SWIG_4(in_pszRtpcName, tempin_gameObjectID, in_uValueChangeDuration, (int)in_eFadeCurve);
return ret;
}
}
示例14: SetMultiplePositions
public static AKRESULT SetMultiplePositions(UnityEngine.GameObject in_GameObjectID, AkPositionArray in_pPositions, ushort in_NumPositions, MultiPositionType in_eMultiPositionType) {
uint tempin_GameObjectID;
if ( in_GameObjectID != null )
{
tempin_GameObjectID = (uint)in_GameObjectID.GetInstanceID();
// Note: if AkGameObjectTracker is already attached, the following code will be bypassed.
if (in_GameObjectID.GetComponent<AkGameObject>() == null)
{
in_GameObjectID.AddComponent<AkGameObject>();
// Note: We have missed AkGameObject.Awake() of this run to register.
// So we take over its work by inlining it here.
AkSoundEngine.RegisterGameObj(in_GameObjectID, in_GameObjectID.name);
//Set the original position
AkSoundEngine.SetObjectPosition(
in_GameObjectID,
in_GameObjectID.transform.position.x,
in_GameObjectID.transform.position.y,
in_GameObjectID.transform.position.z,
in_GameObjectID.transform.forward.x,
in_GameObjectID.transform.forward.y,
in_GameObjectID.transform.forward.z
);
}
}
else
{
tempin_GameObjectID = unchecked((uint)-1);
}
{
AKRESULT ret = (AKRESULT)AkSoundEnginePINVOKE.CSharp_SetMultiplePositions__SWIG_0(tempin_GameObjectID, in_pPositions.m_Buffer, in_NumPositions, (int)in_eMultiPositionType);
return ret;
}
}
示例15: SeekOnEvent
public static AKRESULT SeekOnEvent(uint in_eventID, UnityEngine.GameObject in_gameObjectID, float in_fPercent) {
uint tempin_gameObjectID;
if ( in_gameObjectID != null )
{
tempin_gameObjectID = (uint)in_gameObjectID.GetInstanceID();
// Note: if AkGameObjectTracker is already attached, the following code will be bypassed.
if (in_gameObjectID.GetComponent<AkGameObject>() == null)
{
in_gameObjectID.AddComponent<AkGameObject>();
}
}
else
{
tempin_gameObjectID = unchecked((uint)-1);
}
{
AKRESULT ret = (AKRESULT)AkSoundEnginePINVOKE.CSharp_SeekOnEvent__SWIG_7(in_eventID, tempin_gameObjectID, in_fPercent);
return ret;
}
}