コード例 #1
0
ファイル: IKController.cs プロジェクト: xinge1231/LastDay
    public Transform bodyObj      = null;   // 玩家身体IK标记物

    void Start()
    {
        //
        animator     = GetComponent <Animator>();
        leftHandObj  = UnityTool.findChildGameObject(gameObject, "LeftHandIK").transform;
        rightHandObj = UnityTool.findChildGameObject(gameObject, "RightHandIK").transform;
    }
コード例 #2
0
    public override void setWeapon()
    {
        ICharacter owner  = m_soldierBuildParam.character;
        IWeapon    weapon = FactoryManager.getWeaponFactory().createWeapon(m_soldierBuildParam.weapon);

        weapon.setOwner(owner);
        owner.setWeapon(weapon);

        owner.getGameObject().AddComponent <IKController>();//添加IK控制脚本(注意,是添加在拥有Animator的角色上,不是武器上)
        Vector3 weaponPos = UnityTool.findChildGameObject(owner.getGameObject(), "MainWeaponPos").transform.localPosition;

        UnityTool.attach(owner.getGameObject(), weapon.getGameObject(), weaponPos);
    }
コード例 #3
0
 //寻找Canvas下的指定UI界面对象
 public static GameObject findUIGameObject(string UIName)
 {
     if (m_canvasObj == null)
     {
         //保存当前画布,避免重新搜索
         m_canvasObj = UnityTool.findGameObject("Canvas");
     }
     if (m_canvasObj == null) //当前场景无Canvas
     {
         return(null);
     }
     return(UnityTool.findChildGameObject(m_canvasObj, UIName));
 }
コード例 #4
0
ファイル: IRangedWeapon.cs プロジェクト: xinge1231/LastDay
    //设置特效组件
    public override void setupEffect()
    {
        m_gunEnd = UnityTool.findChildGameObject(m_gameObject, "GunBarrelEnd");
        GameObject shootEffect = FactoryManager.getAssetFactory().loadEffect("ShootEffect");

        UnityTool.attach(m_gunEnd, shootEffect, Vector3.zero);
        m_particles = shootEffect.GetComponent <ParticleSystem>();
        m_audio     = m_gunEnd.GetComponent <AudioSource>();
        m_line      = m_gunEnd.GetComponent <LineRenderer>();
        //m_light = m_gunEnd.GetComponent<Light>();
        m_light = UnityTool.findChildGameObject(m_gunEnd, "FireLight").GetComponent <Light>();

        m_line.SetColors(Color.red, Color.black);
        m_line.SetWidth(0.1f, 0.1f);
    }
コード例 #5
0
    //获取某个UI对象下的指定UI对象的UI组件
    public static T getUIComponent <T>(GameObject container, string UIName) where T : UnityEngine.Component
    {
        GameObject childGameObject = UnityTool.findChildGameObject(container, UIName);

        if (childGameObject == null)
        {
            return(null);
        }
        T tempObj = childGameObject.GetComponent <T> ();

        if (tempObj == null)
        {
            return(null);
        }
        return(tempObj);
    }
コード例 #6
0
ファイル: IPlayer.cs プロジェクト: xinge1231/LastDay
 public override void setGameObject(GameObject theGameObject)
 {
     base.setGameObject(theGameObject);
     m_camera = UnityTool.findChildGameObject(theGameObject, "Camera").GetComponent <Camera>();
 }