コード例 #1
0
ファイル: GameObject.cs プロジェクト: zhangxv12138/SB3Utility
        public GameObject Clone(AssetCabinet file)
        {
            GameObject gameObj = new GameObject(file);

            for (int i = 0; i < m_Component.Count; i++)
            {
                Component asset = m_Component[i].Value.asset;

                Type       t    = asset.GetType();
                MethodInfo info = t.GetMethod("Clone", new Type[] { typeof(AssetCabinet) });
                if (info != null)
                {
                    LinkedByGameObject clone = (LinkedByGameObject)info.Invoke(asset, new object[] { file });
                    gameObj.AddLinkedComponent(clone);
                }
                else
                {
                    string msg = "No Clone method for " + asset.classID2;
                    if (!msgFilter.Contains(msg))
                    {
                        msgFilter.Add(msg);
                        Report.ReportLog(msg);
                    }
                }
            }

            gameObj.m_Layer    = m_Layer;
            gameObj.m_Name     = m_Name;
            gameObj.m_Tag      = m_Tag;
            gameObj.m_isActive = m_isActive;
            return(gameObj);
        }
コード例 #2
0
ファイル: Replace.cs プロジェクト: zhangxv12138/SB3Utility
        public static Transform CreateTransformTree(Animator parser, ImportedFrame frame, Transform parent)
        {
            Transform  trans   = new Transform(parser.file);
            GameObject gameObj = new GameObject(parser.file);

            gameObj.m_Name = (string)frame.Name.Clone();
            UniqueName(parser, gameObj);
            gameObj.AddLinkedComponent(trans);

            parser.m_Avatar.instance.AddBone(parent, trans);

            Vector3    t, s;
            Quaternion r;

            frame.Matrix.Decompose(out s, out r, out t);
            t.X *= -1;
            Vector3 euler = FbxUtility.QuaternionToEuler(r);

            euler.Y *= -1;
            euler.Z *= -1;
            trans.m_LocalRotation = FbxUtility.EulerToQuaternion(euler);
            trans.m_LocalPosition = t;
            trans.m_LocalScale    = s;

            trans.InitChildren(frame.Count);
            for (int i = 0; i < frame.Count; i++)
            {
                trans.AddChild(CreateTransformTree(parser, frame[i], trans));
            }

            return(trans);
        }
コード例 #3
0
ファイル: Replace.cs プロジェクト: hejob/SB3Utility
        public static Transform CloneTransformTree(Animator parser, Transform frame, Transform parent)
        {
            Transform trans = new Transform(parser.file);
            GameObject gameObj = new GameObject(parser.file);
            gameObj.m_Name = (string)frame.m_GameObject.instance.m_Name.Clone();
            UniqueName(parser, gameObj);
            gameObj.AddLinkedComponent(trans);

            parser.m_Avatar.instance.AddBone(parent, trans);

            trans.m_LocalRotation = frame.m_LocalRotation;
            trans.m_LocalPosition = frame.m_LocalPosition;
            trans.m_LocalScale = frame.m_LocalScale;
            CopyUnknowns(frame, trans);

            trans.InitChildren(frame.Count);
            for (int i = 0; i < frame.Count; i++)
            {
                trans.AddChild(CloneTransformTree(parser, frame[i], trans));
            }

            return trans;
        }
コード例 #4
0
ファイル: Replace.cs プロジェクト: zhangxv12138/SB3Utility
        public static Transform CloneTransformTree(Animator parser, Transform frame, Transform parent)
        {
            Transform  trans   = new Transform(parser.file);
            GameObject gameObj = new GameObject(parser.file);

            gameObj.m_Name = (string)frame.m_GameObject.instance.m_Name.Clone();
            UniqueName(parser, gameObj);
            gameObj.AddLinkedComponent(trans);

            parser.m_Avatar.instance.AddBone(parent, trans);

            trans.m_LocalRotation = frame.m_LocalRotation;
            trans.m_LocalPosition = frame.m_LocalPosition;
            trans.m_LocalScale    = frame.m_LocalScale;
            CopyUnknowns(frame, trans);

            trans.InitChildren(frame.Count);
            for (int i = 0; i < frame.Count; i++)
            {
                trans.AddChild(CloneTransformTree(parser, frame[i], trans));
            }

            return(trans);
        }
コード例 #5
0
ファイル: GameObject.cs プロジェクト: hejob/SB3Utility
        public GameObject Clone(AssetCabinet file)
        {
            GameObject gameObj = new GameObject(file);

            for (int i = 0; i < m_Component.Count; i++)
            {
                Component asset = m_Component[i].Value.asset;

                Type t = asset.GetType();
                MethodInfo info = t.GetMethod("Clone", new Type[] { typeof(AssetCabinet) });
                if (info != null)
                {
                    LinkedByGameObject clone = (LinkedByGameObject)info.Invoke(asset, new object[] { file });
                    gameObj.AddLinkedComponent(clone);
                }
                else
                {
                    string msg = "No Clone method for " + asset.classID2;
                    if (!msgFilter.Contains(msg))
                    {
                        msgFilter.Add(msg);
                        Report.ReportLog(msg);
                    }
                }
            }

            gameObj.m_Layer = m_Layer;
            gameObj.m_Name = m_Name;
            gameObj.m_Tag = m_Tag;
            gameObj.m_isActive = m_isActive;
            return gameObj;
        }
コード例 #6
0
ファイル: Replace.cs プロジェクト: hejob/SB3Utility
        public static Transform CreateTransformTree(Animator parser, ImportedFrame frame, Transform parent)
        {
            Transform trans = new Transform(parser.file);
            GameObject gameObj = new GameObject(parser.file);
            gameObj.m_Name = (string)frame.Name.Clone();
            UniqueName(parser, gameObj);
            gameObj.AddLinkedComponent(trans);

            parser.m_Avatar.instance.AddBone(parent, trans);

            Vector3 t, s;
            Quaternion r;
            frame.Matrix.Decompose(out s, out r, out t);
            t.X *= -1;
            Vector3 euler = FbxUtility.QuaternionToEuler(r);
            euler.Y *= -1;
            euler.Z *= -1;
            trans.m_LocalRotation = FbxUtility.EulerToQuaternion(euler);
            trans.m_LocalPosition = t;
            trans.m_LocalScale = s;

            trans.InitChildren(frame.Count);
            for (int i = 0; i < frame.Count; i++)
            {
                trans.AddChild(CreateTransformTree(parser, frame[i], trans));
            }

            return trans;
        }
コード例 #7
0
ファイル: AnimatorEditor.cs プロジェクト: hejob/SB3Utility
        public void MergeFrame(Transform srcFrame, int destParentId)
        {
            Transform srcParent = new Transform(srcFrame.file);
            GameObject srcGameObj = new GameObject(srcFrame.file);
            srcGameObj.AddLinkedComponent(srcParent);
            srcParent.InitChildren(1);
            srcParent.AddChild(srcFrame);

            Transform destParent;
            if (destParentId < 0)
            {
                destParent = new Transform(srcFrame.file);
                GameObject destGameObj = new GameObject(srcFrame.file);
                destGameObj.AddLinkedComponent(destParent);
                destParent.InitChildren(1);
                destParent.AddChild(Parser.RootTransform);
                Parser.m_GameObject.instance.RemoveLinkedComponent(Parser);
            }
            else
            {
                destParent = Frames[destParentId];
            }

            MergeFrame(srcParent, destParent);

            if (destParentId < 0)
            {
                //Parser.RootTransform = srcParent[0];
                srcParent[0].m_GameObject.instance.AddLinkedComponent(Parser);
                srcParent.RemoveChild(0);
                destParent.m_GameObject.instance.RemoveLinkedComponent(destParent);
                srcFrame.file.RemoveSubfile(destParent.m_GameObject.instance);
                srcFrame.file.RemoveSubfile(destParent);
            }

            srcGameObj.RemoveLinkedComponent(srcParent);
            srcFrame.file.RemoveSubfile(srcGameObj);
            srcFrame.file.RemoveSubfile(srcParent);

            if (Parser.file.Bundle != null)
            {
                Parser.file.Bundle.RegisterForUpdate(Parser.m_GameObject.asset);
            }
            InitLists();
            Changed = true;
        }