コード例 #1
0
 public void initializeList()
 {//OYM:一个简单的防报错和把关键词tolower的方法
     if (!(generateKeyWordWhiteList?.Count != 0))
     {
         generateKeyWordWhiteList = settings.defaultKeyWord;
         if (generateKeyWordWhiteList == null)
         {
             Debug.Log("The white key is null!Check the RuntimeController or Global Setting!");
             return;
         }
     }
     else
     {
         for (int i = 0; i < generateKeyWordWhiteList.Count; i++)
         {
             generateKeyWordWhiteList[i] = generateKeyWordWhiteList[i].ToLower();
         }
     }
     for (int i = 0; i < generateKeyWordBlackList.Count; i++)
     {
         generateKeyWordBlackList[i] = generateKeyWordBlackList[i].ToLower();
     }
     if (!generateTransform)
     {
         generateTransform = transform;
     }
     if (settings == null)
     {
         settings = Resources.Load("Setting/ADBGlobalSettingFile") as ADBGlobalSetting;
     }
 }
        public static ADBConstraintReadAndPointControll[] GetJointAndPointControllList(Transform transform, List <string> generateKeyWordWhiteList, List <string> generateKeyWordBlackList, List <Transform> blackListOfGenerateTransform, ADBGlobalSetting settings) //OYM:一个巨啰嗦的方法
        {
            List <ADBRuntimePoint> FixedADBRuntimePoint = searchFixedADBRuntimePoint(transform, generateKeyWordWhiteList, generateKeyWordBlackList, blackListOfGenerateTransform, 0);                                                                                 //OYM:获取所有的固定点,,这里的固定时指那些能动的点的父节点,顺便一提,这个方法顺便把所有节点的子节点赋值了

            if (FixedADBRuntimePoint == null)
            {
                return(null);
            }

            //OYM:在这里对收集好的子节点进行分类与识别
            List <ADBConstraintReadAndPointControll> ADBRuntimeJointAndPointControlls = new List <ADBConstraintReadAndPointControll>();//OYM:

            for (int i = 0; i < FixedADBRuntimePoint.Count; i++)
            {
                Transform parentPoint = FixedADBRuntimePoint[i].trans.parent;
                string    keyWord     = FixedADBRuntimePoint[i].keyWord;
                bool      isContain   = false;
                for (int j0 = 0; j0 < ADBRuntimeJointAndPointControlls.Count; j0++)
                {
                    //OYM:如果包含,就把它加到包含它的controll里面去
                    if (ADBRuntimeJointAndPointControlls[j0].rootNode.trans == parentPoint && ADBRuntimeJointAndPointControlls[j0].keyWord == keyWord)
                    {
                        ADBRuntimeJointAndPointControlls[j0].fixedNodeList.Add(FixedADBRuntimePoint[i]);
                        isContain = true;
                    }
                }
                //OYM:不包含就新建立一个controll,然后加进去
                if (!isContain)
                {
                    ADBSetting setting;
                    if (settings == null)
                    {
                        Debug.Log("Setting File is Lost,check the Resources folder");
                        setting = (ADBSetting)ScriptableObject.CreateInstance(typeof(ADBSetting));
                    }
                    else
                    {
                        setting = settings.GetSetting(keyWord);
                    }

                    ADBRuntimeJointAndPointControlls.Add(new ADBConstraintReadAndPointControll(parentPoint, keyWord, setting));
                    ADBRuntimeJointAndPointControlls[ADBRuntimeJointAndPointControlls.Count - 1].fixedNodeList.Add(FixedADBRuntimePoint[i]);//OYM:给
                }
            }
            //OYM:顺便把所有的fixednode添加给rootnode的childNode
            for (int i = 0; i < ADBRuntimeJointAndPointControlls.Count; i++)
            {
                ADBRuntimeJointAndPointControlls[i].rootNode.childNode = ADBRuntimeJointAndPointControlls[i].fixedNodeList;
            }
            return(ADBRuntimeJointAndPointControlls.ToArray());
        }