Beispiel #1
0
 protected override void CustomRefreshGravity()
 {
     //base.CustomRefreshGravity();
     if (TransTool.IsNull(mTrans) == false)
     {
         bool    isHit  = false;
         Vector3 hitPos = RaycastTool.Raycast(mTrans, Vector3.down, LayerName.Gound, out isHit);
         if (!isHit)
         {
             if (Vector3.Distance(Pos, new Vector3(Pos.x, 0, Pos.z)) > 0)
             {
                 isHit = true;
             }
         }
         if (isHit)
         {
             if (Vector3.Distance(Pos, hitPos) > 0)
             {
                 if (GravityTabTime == 0)
                 {
                     GravityTabTime = Time.realtimeSinceStartup;
                 }
             }
             else
             {
                 GravityTabTime = 0;
             }
         }
     }
 }
Beispiel #2
0
        protected override void CustomInit()
        {
            mLArea  = TransTool.Find(mTrans, "LArea");
            mAreaBg = TransTool.Find(mTrans, "LArea/AreaBg");
            mCircle = TransTool.Find(mTrans, "LArea/Circle");

            mRArea = TransTool.Find(mTrans, "RArea");
        }
Beispiel #3
0
 public Vector3 GetHPRootPos()
 {
     if (TransTool.IsNull(mTrans) == false)
     {
         return(HPRoot.transform.position);
     }
     return(Pos);
 }
Beispiel #4
0
        void Awake()
        {
            mLArea  = TransTool.Find(mTrans, "LArea");
            mAreaBg = TransTool.Find(mTrans, "LArea/AreaBg");
            mCircle = TransTool.Find(mTrans, "LArea/Circle");

            mRArea = TransTool.Find(mTrans, "RArea");
        }
Beispiel #5
0
 private void UpdateOnselfData()
 {
     if (TransTool.IsNull(mTrans))
     {
         return;
     }
     mTrans.position    = Pos;
     mTrans.eulerAngles = Angles;
     mTrans.localScale  = Vector3.one * Scale;
 }
Beispiel #6
0
 public void Init()
 {
     if (UIMgr.UITrans != null)
     {
         Transform trans = TransTool.Find(UIMgr.UITrans, UIName.UILoading);
         if (trans != null)
         {
             mGO = trans.gameObject;
         }
     }
     if (mGO == null)
     {
         AssetsMgr.Instance.LoadPrefab(UIName.UILoading, SuffixTool.Prefab, OnLoadFinish);
     }
 }
Beispiel #7
0
 public virtual void UpdateOneself(GameObject go)
 {
     mOneself    = go;
     mTrans      = Oneself.transform;
     mRoot       = TransTool.Find(mTrans, "Root");
     mHPRoot     = TransTool.Find(mTrans, "Node/hp_root");
     mController = mTrans.GetComponent <CharacterController>();
     //mRendererTool = ConTool.Find<Renderer>(go,"");
     if (mController)
     {
         mController.center = mController.center * Scale;
         mController.height = mController.height * Scale;
         mController.radius = mController.radius * Scale;
     }
     UpdateOnselfData();
     CustomUpdateModel();
 }
Beispiel #8
0
        /// <summary>
        /// 获得控件
        /// </summary>
        /// <typeparam name="T"> 控件类型 </typeparam>
        /// <param name="go"> 父节点 </param>
        /// <param name="path"> 控件路径 </param>
        /// <param name="name"> UI名 </param>
        /// <param name="isChild"> 是否从子节点中获取 </param>
        /// <returns></returns>
        public static T Find <T>(GameObject go, string path, string name = "", bool isChild = false)
        {
            Transform child = TransTool.Find(go.transform, path, name);

            if (child == null)
            {
                MessageBox.Error(string.Format("UI[{0}]中路径[{1}获取Transform失败!!]", name, path), TitleName.TransformFindError);
                return(default(T));
            }
            T t = child.GetComponent <T>();

            if (t == null && isChild == true)
            {
                t = go.GetComponentInChildren <T>();
            }
            if (t == null)
            {
                MessageBox.Error(string.Format("UI[{0}]中路径[{1}获取{3}失败!!]", name, path, typeof(T)), TitleName.TransformFindError);
                return(default(T));
            }
            return(t);
        }
Beispiel #9
0
        public static Component Find(GameObject go, string path, string type, string name = "", bool isChild = false)
        {
            Transform child = TransTool.Find(go.transform, path, name);

            if (child == null)
            {
                MessageBox.Error(string.Format("UI[{0}]中路径[{1}获取Transform失败!!]", name, path), TitleName.TransformFindError);
                return(null);
            }
            Component c = child.GetComponent(type);

            if (c == null && isChild == true)
            {
                c = go.GetComponentInChildren(Type.GetType(type));
            }
            if (c == null)
            {
                MessageBox.Error(string.Format("UI[{0}]中路径[{1}获取{3}失败!!]", name, path, type), TitleName.TransformFindError);
                return(null);
            }
            return(c);
        }
Beispiel #10
0
        /// <summary>
        /// 初始化
        /// </summary>
        public static void Init()
        {
            GameObject   go     = GameObject.FindWithTag(TagName.UICamera);
            Canvas       canvas = null;
            CanvasScaler scaler = null;

            if (go == null)
            {
                go                    = UITool.CreateCanvas("UIRoot");
                go.tag                = TagName.UICamera;
                canvas                = go.GetComponent <Canvas>();
                scaler                = go.GetComponent <CanvasScaler>();
                canvas.renderMode     = RenderMode.ScreenSpaceCamera;
                canvas.pixelPerfect   = false;
                canvas.planeDistance  = 0;
                canvas.sortingLayerID = 1 << LayerName.GetIndexOfLayerName(LayerName.Default);
                UICamera              = CreateCamera("UICamera", 1, go.transform);
                UIFXCamera            = CreateCamera("UIFXCamera", 2, go.transform);
                GameObject ui = new GameObject();
                ui.name             = "UI";
                ui.transform.parent = go.transform;
                UITrans             = ui.transform;
                GameObject fx = new GameObject();
                fx.name             = "FX";
                fx.transform.parent = go.transform;
                FXTrans             = fx.transform;
            }
            else
            {
                UICamera   = ComTool.Find <Camera>(go, "UICamera");
                UIFXCamera = ComTool.Find <Camera>(go, "UIFXCamera");
                UITrans    = TransTool.Find(go.transform, "UI");
                FXTrans    = TransTool.Find(go.transform, "FX");
            }
            if (go != null)
            {
                GameObject.DontDestroyOnLoad(go.transform);
                UIRoot = go;
            }

            /**
             * if (go == null)
             * {
             *  go = UITool.CreateCanvas("UIRoot");
             *  go.tag = TagName.UICamera;
             *  canvas = go.GetComponent<Canvas>();
             *  scaler = go.GetComponent<CanvasScaler>();
             *  canvas.renderMode = RenderMode.ScreenSpaceOverlay;
             *  canvas.pixelPerfect = false;
             *  canvas.sortingOrder = 0;
             *  scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
             *  scaler.referenceResolution = new Vector2(GameSetting.ScreenW, GameSetting.ScreenH);
             *  scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
             *  scaler.matchWidthOrHeight = 1;
             * }
             *
             * Transform UILayerTrans = TransTool.Find(go.transform, "UILayer");
             * if (UILayerTrans == null) UILayer = UITool.CreateCanvas("UILayer", UIRoot.transform);
             * else UILayer = UILayerTrans.gameObject;
             * Transform TipLayerTrans = TransTool.Find(go.transform, "TipLayer");
             * if (TipLayerTrans == null) TipLayer = UITool.CreateCanvas("TipLayer", UIRoot.transform);
             * else TipLayer = UILayerTrans.gameObject;
             */
        }