コード例 #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);
    }
コード例 #2
0
    static void _ProcessTransform(
        Transform transform,
        List <ReducerTask> reducerTasks,
        SABoneColliderBuilder boneColliderBuilder,
        HashSet <Transform> boneHashSet,
        SABoneColliderEditorCommon.BoneMeshCache boneMeshCache)
    {
        if (transform == null || reducerTasks == null || boneColliderBuilder == null ||
            boneHashSet == null || boneMeshCache == null)
        {
            return;
        }

        if (boneHashSet.Contains(transform))
        {
            SABoneCollider boneCollider = transform.gameObject.GetComponent <SABoneCollider>();

            if (boneCollider != null)
            {
                if (boneColliderBuilder.cleanupModified || !boneCollider.modified)
                {
                    SABoneColliderEditorCommon.DestroySABoneCollider(boneCollider);
                    boneCollider = null;
                }

                if (boneCollider != null && boneCollider.recursivery)
                {
                    return;                     // Skip modified children.
                }
            }

            if (boneCollider == null)                 // Don't overwrite modified.
            {
                boneCollider = SABoneColliderEditorCommon.CreateSABoneCollider(transform.gameObject, boneColliderBuilder);
                SABoneColliderEditorCommon.RegistReducerTask(reducerTasks, boneCollider, boneMeshCache);
            }
        }

        foreach (Transform childTransform in transform)
        {
            if (SAColliderBuilderEditorCommon.IsRootTransform(childTransform))
            {
                // Nothing.
            }
            else
            {
                _ProcessTransform(childTransform, reducerTasks, boneColliderBuilder, boneHashSet, boneMeshCache);
            }
        }
    }
コード例 #3
0
    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);
    }