Welcome to Stratos!
Acceder
Portada
Noticias
Trabajo
Colaboración
Enlaces
Foros
IRC
Galería
Miembros
Formación
Nosotros
Inicio
Ayuda
Buscar
Calendario
Ingresar
Registrarse
»
Stratos
»
Principiantes
(Moderador:
[EX3]
) »
c# Unity
« anterior
próximo »
Imprimir
Páginas: [
1
]
Autor
Tema: c# Unity (Leído 937 veces)
paco
Stratos
Mensajes: 29
c# Unity
«
en:
27 de Mayo de 2018, 08:34:29 am »
Hola, hos paso un c# de gran utilidad que yo lo hacia en js con unity y no savia que estaban dejando de utilizarlo, es sencillo de aplicar , biene con el propio unity, y es utilisimo para cambiar graficos por colisiones pero se puede hacer muchisimo mas......
Hos paso mi blog para mas informacion e ideas. Tambien me gustaria alguna opinion...gracias
https://videojuegosenlineaasaco4.blogspot.com.es/p/blog-page_48.html
------------------------Activate Trigger----------------------------------------
using System;
using UnityEngine;
using Object = UnityEngine.Object;
namespace UnityStandardAssets.Utility
{
public class ActivateTrigger : MonoBehaviour
{
// A multi-purpose script which causes an action to occur when
// a trigger collider is entered.
public enum Mode
{
Trigger = 0, // Just broadcast the action on to the target
Replace = 1, // replace target with source
Activate = 2, // Activate the target GameObject
Enable = 3, // Enable a component
Animate = 4, // Start animation on target
Deactivate = 5 // Decativate target GameObject
}
public Mode action = Mode.Activate; // The action to accomplish
public Object target; // The game object to affect. If none, the trigger work on this game object
public GameObject source;
public int triggerCount = 1;
public bool repeatTrigger = false;
private void DoActivateTrigger()
{
triggerCount--;
if (triggerCount == 0 || repeatTrigger)
{
Object currentTarget = target ?? gameObject;
Behaviour targetBehaviour = currentTarget as Behaviour;
GameObject targetGameObject = currentTarget as GameObject;
if (targetBehaviour != null)
{
targetGameObject = targetBehaviour.gameObject;
}
switch (action)
{
case Mode.Trigger:
if (targetGameObject != null)
{
targetGameObject.BroadcastMessage("DoActivateTrigger");
}
break;
case Mode.Replace:
if (source != null)
{
if (targetGameObject != null)
{
Instantiate(source, targetGameObject.transform.position,
targetGameObject.transform.rotation);
DestroyObject(targetGameObject);
}
}
break;
case Mode.Activate:
if (targetGameObject != null)
{
targetGameObject.SetActive(true);
}
break;
case Mode.Enable:
if (targetBehaviour != null)
{
targetBehaviour.enabled = true;
}
break;
case Mode.Animate:
if (targetGameObject != null)
{
targetGameObject.GetComponent<Animation>().Play();
}
break;
case Mode.Deactivate:
if (targetGameObject != null)
{
targetGameObject.SetActive(false);
}
break;
}
}
}
private void OnTriggerEnter(Collider other)
{
DoActivateTrigger();
}
}
}
En línea
Imprimir
Páginas: [
1
]
« anterior
próximo »
»
Stratos
»
Principiantes
(Moderador:
[EX3]
) »
c# Unity
Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.