static void FetchOrCreateEffectors()
        {
            s_ActiveEffectors = new List <RigEffector>();

            PrefabStage prefabStage = PrefabStageUtility.GetCurrentPrefabStage();

            for (int i = 0; i < s_RigBuilders.Count; i++)
            {
                var rigBuilder = s_RigBuilders[i];

                if (rigBuilder == null)
                {
                    continue;
                }

                if (prefabStage != null)
                {
                    StageHandle stageHandle = prefabStage.stageHandle;
                    if (stageHandle.IsValid() && !stageHandle.Contains(rigBuilder.gameObject))
                    {
                        continue;
                    }
                }

                FetchOrCreateEffectors(rigBuilder);

                var rigs = rigBuilder.GetComponentsInChildren <Rig>();
                if (rigs != null)
                {
                    foreach (var rig in rigs)
                    {
                        FetchOrCreateEffectors(rig);
                    }
                }
            }
        }
Beispiel #2
0
        static void DrawSkeletons(SceneView sceneview)
        {
            var gizmoColor = Gizmos.color;

            pyramidMeshRenderer.Clear();
            boxMeshRenderer.Clear();

            for (var i = 0; i < s_BoneRendererComponents.Count; i++)
            {
                var boneRenderer = s_BoneRendererComponents[i];

                if (boneRenderer.bones == null)
                {
                    continue;
                }

                PrefabStage prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
                if (prefabStage != null)
                {
                    StageHandle stageHandle = prefabStage.stageHandle;
                    if (stageHandle.IsValid() && !stageHandle.Contains(boneRenderer.gameObject))
                    {
                        continue;
                    }
                }

                if (boneRenderer.drawBones)
                {
                    var size           = boneRenderer.boneSize * 0.025f;
                    var shape          = boneRenderer.boneShape;
                    var color          = boneRenderer.boneColor;
                    var nubColor       = new Color(color.r, color.g, color.b, color.a);
                    var selectionColor = Color.white;

                    for (var j = 0; j < boneRenderer.bones.Length; j++)
                    {
                        var bone = boneRenderer.bones[j];
                        if (bone.first == null || bone.second == null)
                        {
                            continue;
                        }

                        DoBoneRender(bone.first, bone.second, shape, color, size);
                    }

                    for (var k = 0; k < boneRenderer.tips.Length; k++)
                    {
                        var tip = boneRenderer.tips[k];
                        if (tip == null)
                        {
                            continue;
                        }

                        DoBoneRender(tip, null, shape, color, size);
                    }
                }

                if (boneRenderer.drawTripods)
                {
                    var size = boneRenderer.tripodSize * 0.025f;
                    for (var j = 0; j < boneRenderer.transforms.Length; j++)
                    {
                        var tripodSize = 1f;
                        var transform  = boneRenderer.transforms[j];
                        if (transform == null)
                        {
                            continue;
                        }

                        var position = transform.position;
                        var xAxis    = position + transform.rotation * Vector3.right * size * tripodSize;
                        var yAxis    = position + transform.rotation * Vector3.up * size * tripodSize;
                        var zAxis    = position + transform.rotation * Vector3.forward * size * tripodSize;

                        Handles.color = Color.red;
                        Handles.DrawLine(position, xAxis);
                        Handles.color = Color.green;
                        Handles.DrawLine(position, yAxis);
                        Handles.color = Color.blue;
                        Handles.DrawLine(position, zAxis);
                    }
                }
            }

            pyramidMeshRenderer.Render();
            boxMeshRenderer.Render();

            Gizmos.color = gizmoColor;
        }