示例#1
0
    //-------------------------------------------------------------------------
    protected void UpdateSimilarCollidersAndGroupToTarget(AlphaMeshCollider target)
    {
        string colliderMeshPath = target.FullColliderMeshPath();

        object[] alphaMeshColliders = GameObject.FindSceneObjectsOfType(typeof(AlphaMeshCollider));

        ColliderGroup colliderGroup = FindColliderGroup(colliderMeshPath);

        if (colliderGroup == null)
        {
            // add new group.
            colliderGroup = new ColliderGroup();
            colliderGroup.mFullColliderMeshPath = colliderMeshPath;
            mColliderGroups.Add(colliderGroup);
        }

        AssignValuesFromInstanceToGroup(target, colliderGroup);

        colliderGroup.mAlphaMeshColliderObjects = new List <WeakReference>();
        foreach (AlphaMeshCollider collider in alphaMeshColliders)
        {
            if (collider.FullColliderMeshPath().Equals(colliderMeshPath))
            {
                colliderGroup.mAlphaMeshColliderObjects.Add(new WeakReference(collider));

                // reassign previously calculated values.
                AssignValuesFromColliderGroup(collider, colliderGroup);
            }
        }
    }
示例#2
0
    //-------------------------------------------------------------------------
    public void ReloadOrRecalculateSingleCollider(AlphaMeshCollider target)
    {
        if (!target.CanReloadCollider)
        {
            return;
        }

        string        colliderMeshPath = target.FullColliderMeshPath();
        ColliderGroup colliderGroup    = FindColliderGroup(colliderMeshPath);

        if (colliderGroup == null || !IsColliderGroupValid(colliderGroup))
        {
            if (!target.CanRecalculateCollider)
            {
                return;
            }

            target.RecalculateCollider();
            UpdateSimilarCollidersAndGroupToTarget(target);
        }
        else
        {
            AssignValuesFromColliderGroup(target, colliderGroup);
        }
    }
	//-------------------------------------------------------------------------
	protected void UpdateSimilarCollidersAndGroupToTarget(AlphaMeshCollider target) {
		
		string colliderMeshPath = target.FullColliderMeshPath();
#if UNITY_4_AND_LATER
		object[] alphaMeshColliders = GameObject.FindObjectsOfType(typeof(AlphaMeshCollider));
#else
		object[] alphaMeshColliders = GameObject.FindSceneObjectsOfType(typeof(AlphaMeshCollider));
#endif

		ColliderGroup colliderGroup = FindColliderGroup(colliderMeshPath);
		if (colliderGroup == null) {
			// add new group.
			colliderGroup = new ColliderGroup();
			colliderGroup.mFullColliderMeshPath = colliderMeshPath;
			mColliderGroups.Add(colliderGroup);
		}
		
		AssignValuesFromInstanceToGroup(target, colliderGroup);
		
		colliderGroup.mAlphaMeshColliderObjects = new List<WeakReference>();
		foreach (AlphaMeshCollider collider in alphaMeshColliders)
		{
			if (collider.FullColliderMeshPath().Equals(colliderMeshPath)) {
				
				colliderGroup.mAlphaMeshColliderObjects.Add(new WeakReference(collider));
				
				// reassign previously calculated values.
				AssignValuesFromColliderGroup(collider, colliderGroup);
			}
		}
	}
	//-------------------------------------------------------------------------
	public void ReloadOrRecalculateSingleCollider(AlphaMeshCollider target) {
		if (!target.CanReloadCollider)
			return;
		
		string colliderMeshPath = target.FullColliderMeshPath();
		ColliderGroup colliderGroup = FindColliderGroup(colliderMeshPath);
		if (colliderGroup == null || !IsColliderGroupValid(colliderGroup)) {
			if (!target.CanRecalculateCollider)
				return;
			
			target.RecalculateCollider();
			UpdateSimilarCollidersAndGroupToTarget(target);
		}
		else {
			AssignValuesFromColliderGroup(target, colliderGroup);
		}
	}