//Created by Neodrop
//neodrop@unity3d.ru
using System.Collections.Generic;
using UnityEngine;

public class CsBiped  : MonoBehaviour 
{
    public Transform head, handLeft, handRight, footLeft, footRight;
    public CsBipedBone[] bones; 
    public bool showBones = true;
    public Color colorBone = Color.Lerp(Color.black, Color.green, .7f), colorSelected = Color.Lerp(Color.black, Color.cyan, .75f);

    public void FindBones()
    {
        colorBone = new Color(colorBone.r, colorBone.g, colorBone.b, .45f);
        Transform[] trs = GetComponentsInChildren<Transform>();
        List<CsBipedBone> b = new List<CsBipedBone>();
        int count = trs.Length;
        for (int i = 0; i < count; i++) if (trs[i].gameObject.name.Contains("Bip") || trs[i].gameObject.name.Contains("Bone"))
        {
            CsBipedBone scbb = trs[i].gameObject.GetComponent<CsBipedBone>();
            if (scbb == null) b.Add(trs[i].gameObject.AddComponent<CsBipedBone>());
            else b.Add(scbb);
        }
        bones = new CsBipedBone[b.Count];
        b.CopyTo(bones);
        foreach (CsBipedBone bb in bones) bb.hideFlags = HideFlags.HideInInspector;
    }
}

