本文整理汇总了C#中UnityEngine.GameObject.SendMessageUpwards方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.SendMessageUpwards方法的具体用法?C# GameObject.SendMessageUpwards怎么用?C# GameObject.SendMessageUpwards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.GameObject
的用法示例。
在下文中一共展示了GameObject.SendMessageUpwards方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Press
private void Press(Vector2 screenPos)
{
lastGo = RaycastObject(screenPos);
if (lastGo != null)
{
lastGo.SendMessageUpwards("OnPress", SendMessageOptions.DontRequireReceiver);
}
}
示例2: Attack
void Attack(GameObject go)
{
PlayerAI player = go.GetComponent ("PlayerAI") as PlayerAI;
this.health -= player.strength;
if (health <= 0.1) {
go.SendMessageUpwards("killed", this.gameObject);
Destroy(this.gameObject);
}
}
示例3: attackObject
void attackObject(GameObject go, Vector3 direction, float distance)
{
timeToChangeMoveDirection = changeInterval;
moveDirection = direction;
timeBetweenAttacks -= Time.deltaTime;
if (distance < 1 && timeBetweenAttacks <= 0) {
timeBetweenAttacks = 1.0f;
go.SendMessageUpwards ("Attack", this.gameObject);
}
}
示例4: Update
// Update is called once per frame
void Update()
{
if (!Activated) {
return;
}
Ray ray = new Ray(transform.position, transform.right);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, maxDistance)) {
lineRenderer.SetPosition(1, new Vector3(hit.distance, 0, 0));
Debug.DrawLine(transform.position, hit.point);
if (currentTarget != hit.collider.gameObject) {
currentTarget = hit.collider.gameObject;
currentTarget.SendMessageUpwards("Hit", killTime, SendMessageOptions.DontRequireReceiver);
if (currentTarget.transform.tag.Equals("Player")) {
audioBeamContact.Play();
}
}
}
}
示例5: DoSendMessage
void DoSendMessage(GameObject go)
{
switch (delivery)
{
case MessageType.SendMessage:
switch (functionCall.ParameterType)
{
case "None":
go.SendMessage(functionCall.FunctionName, options);
return;
case "int":
go.SendMessage(functionCall.FunctionName, functionCall.IntParameter.Value, options);
return;
case "float":
go.SendMessage(functionCall.FunctionName, functionCall.FloatParameter.Value, options);
return;
case "string":
go.SendMessage(functionCall.FunctionName, functionCall.StringParameter.Value, options);
return;
case "GameObject":
go.SendMessage(functionCall.FunctionName, functionCall.GameObjectParameter.Value, options);
return;
case "Object":
go.SendMessage(functionCall.FunctionName, functionCall.ObjectReferenceParameter, options);
return;
}
return;
case MessageType.SendMessageUpwards:
switch (functionCall.ParameterType)
{
case "None":
go.SendMessageUpwards(functionCall.FunctionName, options);
return;
case "int":
go.SendMessageUpwards(functionCall.FunctionName, functionCall.IntParameter.Value, options);
return;
case "float":
go.SendMessageUpwards(functionCall.FunctionName, functionCall.FloatParameter.Value, options);
return;
case "string":
go.SendMessageUpwards(functionCall.FunctionName, functionCall.StringParameter.Value, options);
return;
case "GameObject":
go.SendMessage(functionCall.FunctionName, functionCall.GameObjectParameter.Value, options);
return;
case "Object":
go.SendMessageUpwards(functionCall.FunctionName, functionCall.ObjectReferenceParameter, options);
return;
}
return;
case MessageType.BroadcastMessage:
switch (functionCall.ParameterType)
{
case "None":
go.BroadcastMessage(functionCall.FunctionName, options);
return;
case "int":
go.BroadcastMessage(functionCall.FunctionName, functionCall.IntParameter.Value, options);
return;
case "float":
go.BroadcastMessage(functionCall.FunctionName, functionCall.FloatParameter.Value, options);
return;
case "string":
go.BroadcastMessage(functionCall.FunctionName, functionCall.StringParameter.Value, options);
return;
case "GameObject":
go.SendMessage(functionCall.FunctionName, functionCall.GameObjectParameter.Value, options);
return;
case "Object":
go.BroadcastMessage(functionCall.FunctionName, functionCall.ObjectReferenceParameter, options);
return;
}
return;
}
}
示例6: Update
// Update is called once per frame
void Update()
{
//raycast hits object
fwd = mainCamera.transform.TransformDirection (Vector3.forward);
if (gazeTarget == null &&
Physics.Raycast (mainCamera.transform.position, fwd, out hit, 100) &&
hit.collider.tag == "GazeAware" &&
hit.collider != GetComponent<Collider>())
{
gazeTarget = hit.collider.gameObject;
gazeTarget.SendMessageUpwards ("LookedAt");
gazeTarget.SendMessageUpwards ("AttachGazeController", this);
}
else if (gazeTarget != null &&
Physics.Raycast (mainCamera.transform.position, fwd, out hit, 100) &&
hit.collider.gameObject.name == gazeTarget.name)
{
gazeTarget.SendMessageUpwards ("LookedAt");
}
// print ("Gazing " + gazeTarget != null);
}
示例7: sendAction
void sendAction(GameObject target)
{
Debug.Log (target.name);
target.SendMessageUpwards ("Interaction");
}
示例8: BroadcastUpwards
public void BroadcastUpwards(GameObject sender, GameObject receipient)
{
Assert.Test(receipient);
this.sender = sender;
receipient.SendMessageUpwards(string.Format(format, name), this, requireReceiver ? SendMessageOptions.RequireReceiver : SendMessageOptions.DontRequireReceiver);
}