public static void UpdateSpringManagerFromBoneList(SpringManager springManager) { var rootObject = springManager.gameObject; var designatedSpringBones = GetBonesDesignatedForDynamics(rootObject); var currentSpringBones = rootObject.GetComponentsInChildren <SpringBone>(true); var skinBones = GameObjectUtil.GetAllBones(rootObject); var springBonesToDestroy = currentSpringBones .Where(bone => !designatedSpringBones.Contains(bone.gameObject)); foreach (var boneToDestroy in springBonesToDestroy) { var pivot = boneToDestroy.pivotNode; if (pivot != null && SpringBoneSetup.IsPivotProbablySafeToDestroy(pivot, skinBones)) { SpringBoneSetup.DestroyUnityObject(pivot.gameObject); } SpringBoneSetup.DestroyUnityObject(boneToDestroy); } var objectsToAddBonesTo = designatedSpringBones .Where(bone => bone.GetComponent <SpringBone>() == null); foreach (var newBoneOwner in objectsToAddBonesTo) { var newSpringBone = newBoneOwner.AddComponent <SpringBone>(); SpringBoneSetup.CreateSpringPivotNode(newSpringBone); } SpringBoneSetup.FindAndAssignSpringBones(springManager, true); }
// 全子供にSpringBoneを見つけて、springManagerに割り当てる public static void FindAndAssignSpringBones(SpringManager springManager, bool includeInactive = false) { if (springManager != null) { var sortedBones = GetSpringBonesSortedByDepth(springManager.gameObject, includeInactive); springManager.springBones = sortedBones.ToArray(); } }
public void ApplyTo(SpringManager targetManager) { targetManager.automaticUpdates = automaticUpdates; targetManager.simulationFrameRate = simulationFrameRate; targetManager.dynamicRatio = dynamicRatio; targetManager.gravity = gravity; targetManager.collideWithGround = collideWithGround; targetManager.groundHeight = groundHeight; targetManager.bounce = bounce; targetManager.friction = friction; }
private void OnDrawGizmos() { if (shouldDrawGizmosThisFrame || !SpringManager.onlyShowSelectedColliders) { if (manager == null) { manager = GetComponentInParent <SpringManager>(); } DrawGizmos((enabled && manager != null) ? manager.colliderColor : Color.gray); shouldDrawGizmosThisFrame = false; } }
public static PersistentSpringManagerProperties Create(SpringManager sourceManager) { if (sourceManager == null) { return(null); } var properties = new PersistentSpringManagerProperties { automaticUpdates = sourceManager.automaticUpdates, simulationFrameRate = sourceManager.simulationFrameRate, dynamicRatio = sourceManager.dynamicRatio, gravity = sourceManager.gravity, collideWithGround = sourceManager.collideWithGround, groundHeight = sourceManager.groundHeight, bounce = sourceManager.bounce, friction = sourceManager.friction }; return(properties); }
// This should be called by the SpringManager in its Awake function before any updates public void Initialize(SpringManager owner) { manager = owner; var childPosition = ComputeChildPosition(); var localChildPosition = transform.InverseTransformPoint(childPosition); boneAxis = localChildPosition.normalized; initialLocalRotation = transform.localRotation; actualLocalRotation = initialLocalRotation; sphereColliders = sphereColliders.Where(item => item != null).ToArray(); capsuleColliders = capsuleColliders.Where(item => item != null).ToArray(); panelColliders = panelColliders.Where(item => item != null).ToArray(); lengthLimitTargets = (lengthLimitTargets != null) ? lengthLimitTargets.Where(target => target != null).ToArray() : new Transform[0]; InitializeSpringLengthAndTipPosition(); }
private static void UpdateBoneList(SpringManager manager) { SpringBoneSetup.FindAndAssignSpringBones(manager, true); }
private static void SelectAllBones(SpringManager manager) { var bones = manager.GetComponentsInChildren <SpringBone>(true); Selection.objects = bones.Select(item => item.gameObject).ToArray(); }
private static void ShowSpringWindow(SpringManager manager) { SpringBoneWindow.ShowWindow(); }