Example #1
0
        protected UnityNodeData toNodes(GameObject obj, UnityScene unityScene, string modelPath)
        {
            UnityNodeData nodeData = Export.GameObjectToUnityNodeData(obj);

            Transform transform = obj.transform;

            for (int i = 0; i < transform.childCount; i++)
            {
                var child      = transform.GetChild(i);
                var gameObject = child.gameObject;


                // var path = AssetDatabase.GetAssetPath(PrefabUtility.GetCorrespondingObjectFromSource(child.gameObject));

                if (null == gameObject.GetComponent <Animation>())
                {
                    var childNodeData = toNodes(child.gameObject, unityScene, modelPath);
                    if (null != childNodeData)
                    {
                        nodeData.children.Add(childNodeData);
                        childNodeData.parent = nodeData;
                    }
                }
                else
                {
                    //todo Child Mesh
                }
            }


            return(nodeData);
        }
Example #2
0
    public static UnityNodeData GameObjectToUnityNodeData(GameObject obj)
    {
        UnityNodeData data = new UnityNodeData();

        data.name = obj.name;
        Matrix4x4 matrix = TransformToMatrix4x4(obj.transform);

        data.matrix   = Matrix4x4ToBytes(matrix);
        data.children = new List <UnityNodeData>();

        return(data);
    }
        protected Dictionary <string, UnityNodeData> skeletonRoot2Dict(UnityNodeData root, Dictionary <string, UnityNodeData> skeletonDict = null)
        {
            if (null == skeletonDict)
            {
                skeletonDict = new Dictionary <string, UnityNodeData>();
            }

            string name = root.name;

            if (null == name || name == "")
            {
                name = "Auto_Instance_" + nameIndex++;
            }

            skeletonDict[name] = root;

            foreach (var item in root.children)
            {
                skeletonRoot2Dict(item, skeletonDict);
            }

            return(skeletonDict);
        }