Пример #1
0
    static void Process(SABoneCollider boneCollider)
    {
        if (boneCollider == null || boneCollider.colliderProperty == null)
        {
            Debug.LogError("");
            return;
        }

        GameObject rootGameObject = SABoneColliderEditorCommon.GetSABoneColliderRootGameObject(boneCollider);

        if (rootGameObject == null)
        {
            Debug.LogError("");
            return;
        }

        string collidersPath = null;

        if (boneCollider.colliderProperty.isCreateAsset)
        {
            collidersPath = SABoneColliderEditorCommon.GetCollidersPath(rootGameObject);

            if (string.IsNullOrEmpty(collidersPath))
            {
                Debug.LogWarning("Not found collidersPath. Can't create asset.");
            }
        }

        HashSet <Transform> boneHashSet = SABoneColliderEditorCommon.GetBoneHashSet(rootGameObject);

        BoneMeshCache boneMeshCache = new BoneMeshCache();

        boneMeshCache.Process(rootGameObject);

        List <ReducerTask> reducerTasks = new List <ReducerTask>();

        SABoneColliderEditorCommon.CleanupSABoneCollider(boneCollider);
        SABoneColliderEditorCommon.RegistReducerTask(reducerTasks, boneCollider, boneMeshCache);

        SABoneColliderEditorCommon.MarkManualProcessingToParent(boneCollider);

        if (boneCollider.recursivery)
        {
            foreach (Transform childTransform in boneCollider.gameObject.transform)
            {
                if (SAColliderBuilderEditorCommon.IsRootTransform(childTransform))
                {
                    // Nothing.
                }
                else
                {
                    _ProcessTransform(childTransform, reducerTasks, boneCollider, boneHashSet, boneMeshCache);
                }
            }
        }

        SABoneColliderEditorCommon.Reduce(reducerTasks, collidersPath, boneCollider.isDebug);
    }
    static void Process(SABoneColliderBuilder boneColliderBuilder)
    {
        if (boneColliderBuilder == null || boneColliderBuilder.colliderProperty == null)
        {
            Debug.LogError("");
            return;
        }

        string collidersPath = null;

        if (boneColliderBuilder.colliderProperty.isCreateAsset)
        {
            collidersPath = SABoneColliderEditorCommon.GetCollidersPath(boneColliderBuilder.gameObject);

            if (string.IsNullOrEmpty(collidersPath))
            {
                Debug.LogWarning("Not found collidersPath. Can't create asset.");
            }
        }

        HashSet <Transform> boneHashSet = SABoneColliderEditorCommon.GetBoneHashSet(boneColliderBuilder.gameObject);

        SABoneColliderEditorCommon.BoneMeshCache boneMeshCache = new SABoneColliderEditorCommon.BoneMeshCache();
        boneMeshCache.Process(boneColliderBuilder.transform.gameObject);

        List <ReducerTask> reducerTasks = new List <ReducerTask>();

        foreach (Transform transform in boneColliderBuilder.transform)
        {
            if (SAColliderBuilderEditorCommon.IsRootTransform(transform))
            {
                // Nothing.
            }
            else
            {
                _ProcessTransform(transform, reducerTasks, boneColliderBuilder, boneHashSet, boneMeshCache);
            }
        }

        SABoneColliderEditorCommon.Reduce(reducerTasks, collidersPath, boneColliderBuilder.isDebug);
    }