Ejemplo n.º 1
0
 // 全子供にSpringBoneを見つけて、springManagerに割り当てる
 public static void FindAndAssignSpringBones(SpringManager springManager, bool includeInactive = false)
 {
     if (springManager != null)
     {
         var sortedBones = GetSpringBonesSortedByDepth(springManager.gameObject, includeInactive);
         springManager.springBones = sortedBones.ToArray();
     }
 }
Ejemplo n.º 2
0
 public void ApplyTo(SpringManager targetManager)
 {
     targetManager.simulationFrameRate = simulationFrameRate;
     targetManager.dynamicRatio        = dynamicRatio;
     targetManager.gravity             = gravity;
     targetManager.collideWithGround   = collideWithGround;
     targetManager.groundHeight        = groundHeight;
 }
 public static void BrowseAndSaveDynamicsSetup(SpringManager springManager)
 {
     // var path = EditorUtility.SaveFilePanel(
     //     "ダイナミクス情報を保存", "", "", "csv");
     // if (path.Length > 0)
     // {
     //     var sourceText = SpringBoneSerialization.BuildDynamicsSetupString(springManager.gameObject);
     //     if (FileUtil.WriteAllText(path, sourceText))
     //     {
     //         AssetDatabase.Refresh();
     //         Debug.Log("保存しました: " + path);
     //     }
     // }
 }
Ejemplo n.º 4
0
            public static PersistentSpringManagerProperties Create(SpringManager sourceManager)
            {
                if (sourceManager == null)
                {
                    return(null);
                }

                var properties = new PersistentSpringManagerProperties
                {
                    simulationFrameRate = sourceManager.simulationFrameRate,
                    dynamicRatio        = sourceManager.dynamicRatio,
                    gravity             = sourceManager.gravity,
                    collideWithGround   = sourceManager.collideWithGround,
                    groundHeight        = sourceManager.groundHeight
                };

                return(properties);
            }
Ejemplo n.º 5
0
        private void OnDrawGizmos()
        {
            if (!enabled)
            {
                return;
            }

            if (manager == null)
            {
                manager = GetComponentInParent <SpringManager>();
            }

            if (SpringManager.showColliders &&
                !SpringBone.SelectionContainsSpringBones())
            {
                DrawGizmos((manager != null) ? manager.colliderColor : Color.gray);
            }
        }
Ejemplo n.º 6
0
        private void DrawSpringBone(Color drawColor)
        {
            manager = manager ?? gameObject.GetComponentInParent <SpringManager>();
            var childPosition = ComputeChildPosition();

            UnityEditor.Handles.color = drawColor;
            if (manager == null || SpringManager.showBoneSpheres)
            {
                var worldRadius = transform.TransformDirection(radius, 0f, 0f).magnitude;
                // For picking
                Gizmos.color = new Color(0f, 0f, 0f, 0f);
                Gizmos.DrawSphere(childPosition, worldRadius);
                UnityEditor.Handles.RadiusHandle(Quaternion.identity, childPosition, worldRadius);
            }
            UnityEditor.Handles.DrawLine(transform.position, childPosition);

            if (IsRootInsideCollider())
            {
                const float GizmoSize = 0.015f;
                Gizmos.color = Color.yellow;
                Gizmos.DrawWireCube(transform.position, new Vector3(GizmoSize, GizmoSize, GizmoSize));
            }
        }
Ejemplo n.º 7
0
        private void Awake()
        {
            AutoAssignChild();

            initialLocalRotation = transform.localRotation;
            actualLocalRotation  = initialLocalRotation;
            manager = transform.GetComponentInParent <SpringManager>();

            sphereColliders  = sphereColliders.Where(item => item != null).ToArray();
            capsuleColliders = capsuleColliders.Where(item => item != null).ToArray();
            panelColliders   = panelColliders.Where(item => item != null).ToArray();

            if (lengthLimitTargets == null)
            {
                lengthLimitTargets = new Transform[0];
            }
            else
            {
                lengthLimitTargets = GameObjectUtil.RemoveNulls(lengthLimitTargets).ToArray();
            }

            InitializeSpringLengthAndTipPosition();
        }
Ejemplo n.º 8
0
 private void Awake()
 {
     manager       = GetComponentInParent <SpringManager>();
     colliderDebug = new SpringColliderDebug();
 }
 private static void SaveDynamicsToCSV(SpringManager manager)
 {
     BrowseAndSaveDynamicsSetup(manager);
 }
 private static void LoadDynamicsFromCSV(SpringManager manager)
 {
     BrowseAndLoadDynamicsSetup(manager.gameObject);
 }
        // private

        private static void UpdateBoneList(SpringManager manager)
        {
            // Undo.RecordObject(manager, "Update Bone List");
            // SpringBoneSetup.FindAndAssignSpringBones(manager, true);
        }