Exemple #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 Cleanup(SABoneCollider boneCollider)
    {
        if (boneCollider == null)
        {
            Debug.LogError("");
            return;
        }

        GameObject rootGameObject = SABoneColliderEditorCommon.GetSABoneColliderRootGameObject(boneCollider);

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

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

        bool cleanupModified = boneCollider.cleanupModified;

        SABoneColliderEditorCommon.CleanupSABoneCollider(boneCollider);

        SABoneColliderEditorCommon.MarkManualProcessingToParent(boneCollider);

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