Exemple #1
0
        private void DrawSpriteColliderInfo()
        {
            ShowUtil.DrawTitle("代表本体的碰撞信息", Color.magenta);
            ShowUtil.DrawLine();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("重置", GUILayout.Width(120f)))
            {
                SetSpriteCollider();
            }
            GUILayout.EndHorizontal();
            if (spriteInfo.spriteCollider == null)
            {
                EditorUtils.DrawNoCollider();
                return;
            }

            ObjCollider objCollider = spriteInfo.spriteCollider;

            EditorGUI.indentLevel += 2;
            EditorGUILayout.ObjectField("碰撞体",
                                        objCollider,
                                        typeof(ObjCollider), true);
            objCollider.gameObject.layer = EditorGUILayout.LayerField("碰撞体层级", objCollider.gameObject.layer, GUILayout.ExpandWidth(true));
            EditorGUILayout.ObjectField("信息体", objCollider.info, typeof(ObjInfo), true);
            EditorGUI.indentLevel -= 2;
        }
Exemple #2
0
        private void SetSpriteCollider()
        {
            ObjCollider spriteCollider = spriteInfo.spriteCollider;

            if (spriteCollider == null)
            {
                Transform colliderTrans = charater.transform.Find("collider");
                if (null == colliderTrans)
                {
                    GameObject go = new GameObject("collider");
                    colliderTrans = go.transform;
                    colliderTrans.SetParent(charater.transform);
                }
                spriteCollider = colliderTrans.GetComponent <ObjCollider>();
                if (spriteCollider == null)
                {
                    spriteCollider = colliderTrans.gameObject.AddComponent <ObjCollider>();
                }
                spriteInfo.spriteCollider = spriteCollider;
            }
            spriteCollider.collider = spriteCollider.gameObject.GetComponent <CapsuleCollider>();
            if (spriteCollider.collider == null)
            {
                spriteCollider.collider = spriteCollider.gameObject.AddComponent <CapsuleCollider>();
            }

            spriteCollider.gameObject.layer = Const.LAYER_MONSTER_COLLIDER;
            spriteCollider.info             = spriteInfo;
        }
Exemple #3
0
        private void SetItemCollider()
        {
            ObjCollider itemCollider = itemInfo.itemCollider;

            if (itemCollider == null)
            {
                Transform colliderTrans = item.transform.Find("collider");
                if (null == colliderTrans)
                {
                    GameObject go = new GameObject("collider");
                    colliderTrans = go.transform;
                    colliderTrans.SetParentIndentical(item.transform);
                }
                itemCollider = colliderTrans.GetComponent <ObjCollider>();
                if (itemCollider == null)
                {
                    itemCollider = colliderTrans.gameObject.AddComponent <ObjCollider>();
                }
                itemInfo.itemCollider = itemCollider;
            }
            itemCollider.collider = itemCollider.gameObject.GetComponent <CapsuleCollider>();
            if (itemCollider.collider == null)
            {
                itemCollider.collider = itemCollider.gameObject.AddComponent <CapsuleCollider>();
            }

            itemCollider.gameObject.layer = Const.LAYER_ITEM_COLLIDER;
            itemCollider.info             = itemInfo;
        }