示例#1
0
        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
文件: Unity3d.cs 项目: kkdevs/sb3u
 public static void RemoveAsset([DefaultVar] UnityParser parser, Component asset)
 {
     if (asset.classID() == UnityClassID.AssetBundle)
     {
         return;
     }
     if (asset is NotLoaded)
     {
         Component loadedAsset = parser.Cabinet.LoadComponent(((NotLoaded)asset).pathID);
         if (loadedAsset != null)
         {
             asset = loadedAsset;
         }
     }
     if (asset is LinkedByGameObject)
     {
         LinkedByGameObject linked = (LinkedByGameObject)asset;
         if (linked.m_GameObject != null && linked.m_GameObject.instance != null)
         {
             linked.m_GameObject.instance.RemoveLinkedComponent(linked);
         }
     }
     parser.Cabinet.RemoveSubfile(asset);
     if (asset.classID() == UnityClassID.Texture2D || asset.classID() == UnityClassID.Cubemap)
     {
         parser.Textures.Remove(asset);
     }
     if (parser.Cabinet.Bundle != null)
     {
         parser.Cabinet.Bundle.DeleteComponent(asset);
     }
 }
示例#3
0
 public void RemoveLinkedComponent(LinkedByGameObject asset)
 {
     for (int i = 0; i < m_Component.Count; i++)
     {
         if (m_Component[i].Value.asset == asset)
         {
             m_Component.RemoveAt(i);
             break;
         }
     }
     if (m_Component.Count == 0)
     {
         file.RemoveSubfile(this);
     }
     asset.m_GameObject = new PPtr <GameObject>((LinkedByGameObject)null);
 }
示例#4
0
 public void UpdateComponentRef(LinkedByGameObject oldComp, LinkedByGameObject newComp)
 {
     for (int i = 0; i < m_Component.Count; i++)
     {
         if (m_Component[i].Value == newComp)
         {
             return;
         }
         if (m_Component[i].Value.asset == oldComp)
         {
             var newRef =
                 new KeyValuePair <UnityClassID, PPtr <Component> >
                 (
                     newComp.classID2,
                     new PPtr <Component>(newComp)
                 );
             m_Component.RemoveAt(i);
             m_Component.Insert(i, newRef);
             newComp.m_GameObject = new PPtr <GameObject>(this);
             return;
         }
     }
 }
示例#5
0
 public void RemoveLinkedComponent(LinkedByGameObject asset)
 {
     for (int i = 0; i < m_Component.Count; i++)
     {
         if (m_Component[i].Value.asset == asset)
         {
             m_Component.RemoveAt(i);
             break;
         }
     }
     if (m_Component.Count == 0)
     {
         file.RemoveSubfile(this);
     }
     asset.m_GameObject = new PPtr<GameObject>((LinkedByGameObject)null);
 }
示例#6
0
 public void AddLinkedComponent(LinkedByGameObject asset)
 {
     m_Component.Add(new KeyValuePair<UnityClassID, PPtr<Component>>(asset.classID1, new PPtr<Component>(asset)));
     asset.m_GameObject = new PPtr<GameObject>(this);
 }
示例#7
0
 public void AddLinkedComponent(LinkedByGameObject asset)
 {
     m_Component.Add(new KeyValuePair <UnityClassID, PPtr <Component> >(asset.classID1, new PPtr <Component>(asset)));
     asset.m_GameObject = new PPtr <GameObject>(this);
 }