public ADBRuntimeColliderControll(GameObject character, List <ADBRuntimePoint> allPointTrans, bool isGenerateBodyRuntimeCollider, bool isGenerateScript, bool isGenerateFinger, out List <ADBEditorCollider> editorColliderList)
        {
            runtimeColliderList = new List <ADBRuntimeCollider>();
            editorColliderList  = new List <ADBEditorCollider>();

            initialized = false;
            bool iniA = false, iniB = false, iniC = false;

            if (isGenerateBodyRuntimeCollider)
            {
                iniA = GenerateBodyCollidersData(ref runtimeColliderList, character, allPointTrans, isGenerateFinger);
            }
            if (isGenerateScript)
            {
                for (int i = 0; i < runtimeColliderList.Count; i++)
                {
                    if (runtimeColliderList[i].appendTransform == null)
                    {
                        continue;
                    }

                    ADBEditorCollider.RuntimeCollider2Editor(runtimeColliderList[i]);
                }
            }
            iniB = GenerateOtherCollidersData(ref runtimeColliderList, ref editorColliderList, character);
            for (int i = 0; i < runtimeColliderList.Count; i++)
            {//OYM:这个设置可以帮助你的collider跟随你的角色一起发生尺寸变化
                //OYM:某些特殊的情况,你可以关闭它
                runtimeColliderList[i].colliderRead.isConnectWithBody = true;
            }
            iniC = GenerateGlobalCollidersData(ref runtimeColliderList);

            initialized = iniA || iniB || iniC;

            if (initialized && Application.isPlaying)
            {
                colliderTransform       = new Transform[runtimeColliderList.Count];
                collidersReadTable      = new ColliderRead[runtimeColliderList.Count];
                collidersReadWriteTable = new ColliderReadWrite[runtimeColliderList.Count];

                for (int i = 0; i < runtimeColliderList.Count; i++)
                {
                    collidersReadTable[i] = runtimeColliderList[i].GetColliderRead();
                    colliderTransform[i]  = runtimeColliderList[i].appendTransform;
                }
            }
            if (!initialized)
            {
                Debug.Log("SomeThing in ADBRuntimeColliderControll is wrong....");
            }
        }
        public void initializeCollider(bool generateScript, bool isFixedPoint)
        {
            List <ADBRuntimePoint> list = null;

            if (jointAndPointControlls == null || jointAndPointControlls.Length == 0)
            {
                Debug.Log("use <generate Point> to get higher accuate collider");
            }
            else
            {
                list = new List <ADBRuntimePoint>();
                for (int i = 0; i < jointAndPointControlls.Length; i++)
                {
                    if (isFixedPoint)
                    {
                        list.AddRange(jointAndPointControlls[i].fixedNodeList);
                    }
                    else
                    {
                        list.AddRange(jointAndPointControlls[i].allNodeList);
                    }
                }
            }

            colliderControll = new ADBRuntimeColliderControll(gameObject, list, isGenerateColliderAutomaitc);//OYM:在这里获取collider
            if (generateScript)
            {
                editorColliderList = new List <ADBEditorCollider>();
                var OtheerColliderList = gameObject.GetComponentsInChildren <ADBEditorCollider>();
                for (int i = 0; i < colliderControll.runtimeColliderList.Count; i++)
                {
                    if (colliderControll.runtimeColliderList[i].appendTransform == null)
                    {
                        continue;
                    }

                    ADBEditorCollider.RuntimeCollider2Editor(colliderControll.runtimeColliderList[i], ref editorColliderList);
                }
                editorColliderList.AddRange(OtheerColliderList);
                for (int i = 0; i < editorColliderList.Count; i++)
                {
                    editorColliderList[i].isDraw = true;
                }
                isGenerateColliderAutomaitc = false;
            }
        }
Exemplo n.º 3
0
 public void OnEnable()
 {
     controller = (target as ADBEditorCollider);
 }