Beispiel #1
0
    void SetCurPosture(GameObject root, _PostureData postureData)
    {
        if (root == null)
        {
            /*Debug.LogError("ROOT IS NULL!");*/
            return;
        }

        if (postureData == null)
        {
            /*Debug.LogError("DATA IS NULL!");*/
            postureData = initialPose != null ? initialPose : defaultPose;
        }

        List <Transform> children = new List <Transform>();

        root.GetComponentsInChildren <Transform>(children);

        foreach (Transform child in children)
        {
            _SkeletonData dest = postureData.data.Find(x => x.name == child.name);
            if (dest != null)
            {
                child.position    = new Vector3(dest.positionF[0], dest.positionF[1], dest.positionF[2]);
                child.eulerAngles = new Vector3(dest.eulerAnglesF[0], dest.eulerAnglesF[1], dest.eulerAnglesF[2]);

                /*Debug.Log(string.Format("{0} : pos : {1}, angle : {2}",child.name, child.position, child.eulerAngles));*/
            }
        }
    }
Beispiel #2
0
    public void UpdatePosture(_SourceItemData item, bool toSelect, bool isInitial)
    {
        _PostureData postureData = GetPostureData(item);

        if (postureData == null)
        {
            return;
        }

        if (isInitial)
        {
            initialPose = postureData;
            /*Debug.Log (item.title + "Set Posture to default");*/
        }

        ///Show
        if (toSelect)
        {
            /*Debug.Log ("Accessory Selected !");*/
            if (postureData == currentPose)
            {
                Debug.Log("There must be something wrong!");
                return;
            }
            else
            {
                currentPose = postureData;
            }

            ///Hide
        }
        else
        {
            /*Debug.Log ("Accessory Reselesed !");*/
            if (postureData == currentPose)
            {
                currentPose = initialPose;
            }
            else
            {
                Debug.Log("There must be something else wrong!");
            }
        }
    }
Beispiel #3
0
    static void CreatePostTextAsset()
    {
        string rootPath = AssetDatabase.GetAssetPath(Selection.activeObject);

        string[] existingAssetbundles = Directory.GetFiles(rootPath, "*.txt", SearchOption.AllDirectories);
        foreach (string bundle in existingAssetbundles)
        {
            Debug.Log(bundle);

            if (bundle.EndsWith(".txt") && bundle.Contains("pose"))
            {
                File.Delete(bundle);
            }
        }

        foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets))
        {
            if (o.name.Contains("_pose_"))
            {
                GameObject poseObj   = o as GameObject;
                GameObject poseClone = (GameObject)Object.Instantiate(poseObj);

                string path = rootPath + "/pose.txt";

                List <_SkeletonData> skeleton = new List <_SkeletonData>();
                Transform            root     = poseClone.transform;
                AddSkelet(root, ref skeleton);
                AddChildrenSkelets(root, ref skeleton);

                _PostureData postureData = new _PostureData()
                {
                    data = skeleton
                };
                _InternalDataCodec.SaveString(JsonFx.Json.JsonWriter.Serialize(postureData), path);

                Object.DestroyImmediate(poseClone);
            }
        }
    }