Example #1
0
    public void delObj(Object ob, string id)
    {
        if (isWrong(ob))
        {
            XDebug.LogError("delObj空对象");
            return;
        }

        if (_objDestroy != null)
        {
            _objDestroy(ob, id);
        }

        List <object> pool = null;

        if (_pool.ContainsKey(id))
        {
            pool = _pool[id];
        }
        else
        {
            pool      = new List <object>();
            _pool[id] = pool;
        }

        if (pool.Count <= _maxSize)
        {
            pool.Add(ob);
        }
        else if (_realDestroy != null)
        {
            _realDestroy(ob, id);
        }
    }
Example #2
0
    // 文件拷贝
    public static bool copyDirectory(string sourceDirName, string destDirName, bool copySubDirs)
    {
        DirectoryInfo dir = new DirectoryInfo(sourceDirName);

        if (!dir.Exists)
        {
            XDebug.LogError("源目录不存在拷贝失败" + sourceDirName);
            return(false);
        }

        DirectoryInfo[] dirs = dir.GetDirectories();
        if (!Directory.Exists(destDirName))
        {
            Directory.CreateDirectory(destDirName);
        }

        FileInfo[] files = dir.GetFiles();
        foreach (FileInfo file in files)
        {
            string temppath = Path.Combine(destDirName, file.Name);
            file.CopyTo(temppath, false);
        }

        if (copySubDirs)
        {
            foreach (DirectoryInfo subdir in dirs)
            {
                string temppath = Path.Combine(destDirName, subdir.Name);
                copyDirectory(subdir.FullName, temppath, copySubDirs);
            }
        }
        return(true);
    }
Example #3
0
    public bool ReadFile(Stream stream)
    {
        lineno   = 0;
        columnno = -1;
        BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.UTF8);

        {
            long fileSize  = reader.ReadInt64();
            int  lineCount = reader.ReadInt32();
            OnClear(lineCount);
            for (int i = 0; i < lineCount; ++i)
            {
                ReadLine(reader);
                ++lineno;
                if (columnno > 0)
                {
                    break;
                }
            }
            long pos = reader.BaseStream.Position;
            if (pos != fileSize)
            {
                XDebug.LogError("read table error: " + this.GetType().Name, " size:" + fileSize, " pos:" + pos, " stream: " + stream.Length);
            }
        }
        reader.Close();
        return(columnno == -1);
    }
Example #4
0
        private static void SaveMeshAsset(Mesh mesh, Texture2D tex, int profession, string path)
        {
            int uvOffsetX = GetUVOffset(profession, mesh.name, s_CombineConfig);

            if (uvOffsetX >= 0)
            {
                ReCalculateUV(mesh, uvOffsetX);
            }
            else
            {
                XDebug.LogError("Find UV Error:", mesh.name);
            }

            CleanMesh(mesh);
            string meshPath = path + mesh.name + ".asset";

            AssetDatabase.CreateAsset(mesh, meshPath);
            if (tex != null)
            {
                string srcTexPath  = AssetDatabase.GetAssetPath(tex);
                string destTexPath = "Assets/Resources/Equipments/" + tex.name + ".tga";
                AssetDatabase.CopyAsset(srcTexPath, destTexPath);
            }
            AssetDatabase.SaveAssets();
        }
Example #5
0
    public void Init(byte[] bytes)
    {
        MemoryStream depStream = new MemoryStream(bytes);

        if (depStream.Length > 4)
        {
            BinaryReader br = new BinaryReader(depStream);
            if (br.ReadChar() == 'A' && br.ReadChar() == 'B' && br.ReadChar() == 'D')
            {
                if (br.ReadChar() == 'T')
                {
                    depInfoReader = new AssetBundleDataReader();
                }
                else
                {
                    depInfoReader = new AssetBundleDataBinaryReader();
                }
                depStream.Position = 0;
                depInfoReader.Read(depStream);
            }
            else
            {
                XDebug.LogError("not find dep");
            }
        }
        depStream.Close();
    }
Example #6
0
    public static Stream ReadText(string location, bool error = true)
    {
        TextAsset data = Load <TextAsset>(location, AssetType.Text);

        if (data == null)
        {
            if (error)
            {
                XDebug.LogError("Load resource: ", location, " error!");
            }
            return(null);
        }
        try
        {
            _share_stream.SetLength(0);
            _share_stream.Write(data.bytes, 0, data.bytes.Length);
            _share_stream.Seek(0, SeekOrigin.Begin);
            return(_share_stream);
        }
        catch (System.Exception e)
        {
            XDebug.Log(e.Message, location);
            return(_share_stream);
        }
        finally
        {
            Resources.UnloadAsset(data);
        }
    }
        public override void Initialize()
        {
            single = this;
            base.Initialize();

            if (initialized)
            {
                return;
            }

            initialized = true;

            // populate the lookup dictionary
            for (int i = 0; i < hitGroupTags.Count; i++)
            {
                if (rewindLayerTagToId.ContainsKey(hitGroupTags[i]))
                {
                    XDebug.LogError(!XDebug.logErrors ? null : ("The tag '" + hitGroupTags[i] + "' is used more than once in NSTRewindSettings. Repeats will be discarded, which will likely break some parts of rewind until they are removed."));
                }
                else
                {
                    rewindLayerTagToId.Add(hitGroupTags[i], i);
                }
            }

            XDebug.Log(!XDebug.logInfo ? null : ("Initialized HitGroupMasterSettings - Total Layer Tags Count: " + hitGroupTags.Count));
        }
Example #8
0
 private static void ErrorReceived(object sender, DataReceivedEventArgs eventArgs)
 {
     if (eventArgs.Data != null)
     {
         XDebug.LogError(eventArgs.Data);
     }
 }
Example #9
0
    static void OnInitCallback(byte t, IntPtr ptr)
    {
        string command = Marshal.PtrToStringAnsi(ptr);

        switch (t)
        {
        case ASCII.L:
            XDebug.CLog(command);
            break;

        case ASCII.W:
            XDebug.CWarn(command);
            break;

        case ASCII.E:
            XDebug.CError(command);
            break;

        case ASCII.G:
            GameObject go = XResources.Load <GameObject>(command, AssetType.Prefab);
            go.name = command;
            break;

        case ASCII.U:
            XDebug.CLog("unload: " + command);
            break;

        default:
            XDebug.LogError(t + " is not parse symbol: " + command);
            break;
        }
    }
Example #10
0
    bool read_dict(Dictionary <string, object> dict)
    {
        oldver = readString(dict, "oldver");
        if (oldver == "")
        {
            XDebug.LogError("配置文件oldver错误");
            return(false);
        }

        newver = readString(dict, "newver");
        if (newver == "")
        {
            XDebug.LogError("配置文件newver错误");
            return(false);
        }

        alreadyDownloadDict.Clear();
        Dictionary <string, object> infoDict = dict["downloadDict"] as Dictionary <string, object>;

        foreach (var info in infoDict)
        {
            Dictionary <string, object> asInfoDict = info.Value as Dictionary <string, object>;
            XBundleInfo assetInfo = new XBundleInfo();
            assetInfo.read_dict(asInfoDict);
            alreadyDownloadDict[info.Key] = assetInfo;
        }

        return(true);
    }
Example #11
0
        private static bool _Check(GameObject go, string path)
        {
            GameObject      prefab    = GameObject.Instantiate(go) as GameObject;
            List <Renderer> renderLst = new List <Renderer>();

            prefab.GetComponentsInChildren <Renderer>(renderLst);

            int renderCount = 0;

            for (int i = 0; i < renderLst.Count; ++i)
            {
                Renderer render = renderLst[i];
                if (render != null)
                {
                    if (render.receiveShadows || render.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On)
                    {
                        XDebug.LogError(string.Format("Error Shadow cast:{0} render:{1}", go.name, render.name));
                    }
                    if (render.sharedMaterials.Length > 1)
                    {
                        str += string.Format("Too many materials:{0} render:{1} count:{2}\r\n", go.name, render.name, render.sharedMaterials.Length);
                    }
                    if (!(render is ParticleSystemRenderer))
                    {
                        renderCount++;
                    }
                }
            }
            if (renderCount > 1)
            {
                str += string.Format("Too many renders:{0} count:{1}\r\n", go.name, renderCount);
            }
            GameObject.DestroyImmediate(prefab);
            return(true);
        }
Example #12
0
    static void OnEntityCallback(uint entityid, byte command, uint arg)
    {
        switch (command)
        {
        case ASCII.E:
            NativeEntityMgr.singleton.Add <NativeEntity>(entityid, arg);
            break;

        case ASCII.R:
            NativeEntityMgr.singleton.Add <NativeRole>(entityid, arg);
            break;

        case ASCII.P:
            NativeEntityMgr.singleton.Player =
                NativeEntityMgr.singleton.Add <NativePlayer>(entityid, arg);
            break;

        case ASCII.M:
            NativeEntityMgr.singleton.Add <NativeMonster>(entityid, arg);
            break;

        case ASCII.N:
            NativeEntityMgr.singleton.Add <NativeNPC>(entityid, arg);
            break;

        case ASCII.U:
            NativeEntityMgr.singleton.Remv(entityid);
            break;

        default:
            XDebug.LogError("not regist command ", command);
            break;
        }
    }
Example #13
0
    static void OnEntitySync(uint entityid, byte command, ref VectorArr vec)
    {
        NativeEntity entity = NativeEntityMgr.singleton.Get(entityid);

        switch (command)
        {
        case ASCII.p:
            Vector3 pos = vec.ToVector();
            pos.y = NativeScene.singleton.TerrainY(pos);
            entity.transfrom.position = pos;
            break;

        case ASCII.s:
            entity.transfrom.localScale = vec.ToVector();
            break;

        case ASCII.r:
            entity.transfrom.rotation = Quaternion.Euler(vec.ToVector());
            break;

        case ASCII.f:
            entity.transfrom.forward = vec.ToVector();
            break;

        default:
            XDebug.LogError("not regist command ", command);
            break;
        }
    }
Example #14
0
File: XVer.cs Project: YoMi-w/Slua-
    bool read_dict(Dictionary <string, object> dict)
    {
        ver = readString(dict, "ver");
        if (ver == "")
        {
            XDebug.LogError("远程版本文件ver字段错误");
            return(false);
        }

        ab = readString(dict, "ab");
        if (ab == "")
        {
            XDebug.LogError("远程版本文件ab字段错误");
            return(false);
        }

        remoteLogUrl = readString(dict, "remoteLogUrl");
        if (remoteLogUrl == "")
        {
            XDebug.LogError("远程版本文件ab字段错误");
            return(false);
        }

        isRemoteLog = readBool(dict, "isRemoteLog");
        return(true);
    }
Example #15
0
    static void OnComponentCallback(uint entityid, byte command, string arg)
    {
        NativeEntity entity = NativeEntityMgr.singleton.Get(entityid);

        switch (command)
        {
        case ASCII.C:
        {
            NativeEquipComponent ne = entity.GetComponent <NativeEquipComponent>();
            ne.ChangeHairColor(Color.red);
        }
        break;

        case ASCII.W:
        {
            NativeEquipComponent ne = entity.GetComponent <NativeEquipComponent>();
            ne.AttachWeapon(arg);
        }
        break;

        default:
            XDebug.LogError("not regist command ", command);
            break;
        }
    }
Example #16
0
 public bool Unload(IUIDlg dlg)
 {
     if (Exist(dlg))
     {
         if (dlg.pushStack)
         {
             var v = m_stack.Peek();
             if (v.id == dlg.id)
             {
                 DestroyDlg(dlg);
                 m_stack.Pop();
             }
             else
             {
                 XDebug.LogError("dlg is not in stack ", dlg.fileName);
             }
         }
         else
         {
             for (int i = 0, max = m_list.Count; i < max; i++)
             {
                 if (m_list[i].id == dlg.id)
                 {
                     DestroyDlg(dlg);
                     m_list.RemoveAt(i);
                     break;
                 }
             }
         }
         return(true);
     }
     return(false);
 }
        /// <summary>
        /// Finds UI Elements. If none found will create them and return false to indicate that placeholders are being used.
        /// </summary>
        /// <returns></returns>
        public bool FindUIElement()
        {
            // First see if this is on a canvas, if so note it
            if (!canvas)
            {
                canvas = GetComponent <Canvas>();
            }

            // Is this a placeholder canvas we just created for another bar?
            if (canvas && canvas.gameObject.name == PLACEHOLDER_CANVAS_NAME)
            {
                // This means another HealthUI created a placeholder, so we will use that canvas.
            }
            // If we have a canvas then search for the text/images
            else if (canvas)
            {
                if (canvas.gameObject.name != PLACEHOLDER_CANVAS_NAME)
                {
                    if (!UIText)
                    {
                        UIText = (searchChildren) ? canvas.GetComponentInChildren <Text>() : canvas.GetComponent <Text>();
                    }

                    if (!UIImage)
                    {
                        UIImage = (searchChildren) ? canvas.GetComponentInChildren <Image>() : canvas.GetComponent <Image>();
                    }
                }
            }
            // No canvas, so this may be the UI Element itself this is attached to
            else
            {
                if (!UIText)
                {
                    UIText = (searchChildren) ? GetComponentInChildren <Text>() : GetComponent <Text>();
                }

                if (!UIImage)
                {
                    UIImage = (searchChildren) ? GetComponentInChildren <Image>() : GetComponent <Image>();
                }
            }

            // If nothing was found after all of that - we need to make a canvas and UI elements.
            if (!UIText && !UIImage)
            {
                XDebug.LogWarning(!XDebug.logWarnings ? null : ("NSTSampleHealthUI on gameobject '" + name + "' cannot find any UI Canvas, Text or Image. Will create some placeholders until you supply them."), nst);
                XDebug.LogError(!XDebug.logErrors ? null : ("NSTSampleHealthUI on gameobject '" + name + "' cannot find a NetworkSyncTransform, UI Text, or UI Image component. Be sure the object we are attaching to conains one of those."), !nst);

                // Put some bars of this things head if it is an NST - Otherwise they won't make much sense on other objects.
                if (nst)
                {
                    CreatePlaceholderVitalBar(monitoredVitalId);
                }

                return(false);
            }
            return(true);
        }
 public string GetBundleNameByAssetName(string assetName)
 {
     if (m_dictAssetNameToBundleName.ContainsKey(assetName))
     {
         return(m_dictAssetNameToBundleName[assetName]);
     }
     XDebug.LogError(XABConst.Tag, $"无法找到该资源对应的包名 {assetName}");
     return(string.Empty);
 }
Example #19
0
        public void Register(Component receiver, int signal, Action <Component> callback)
        {
            if (callback == null)
            {
                XDebug.LogError(receiver, "Missing callback.");
                return;
            }

            Register(receiver, signal, (sender, data) => callback(sender));
        }
Example #20
0
        public void AddRootTargets(FileInfo file)
        {
            AssetTarget target = AssetBundleUtil.Load(file);

            if (target == null)
            {
                XDebug.LogError(file);
            }
            target.exportType = AssetBundleExportType.Root;
        }
Example #21
0
        public static int LookupId(string name)
        {
            Initialize();
            if (s_NamesToIds.ContainsKey(name))
            {
                return(s_NamesToIds[name]);
            }

            XDebug.LogError("Couldn't find signal named '" + name + "'.");
            return(None);
        }
Example #22
0
        public bool IsTalkScript(string funcName)
        {
            if (!_LevelScripts.ContainsKey(funcName))
            {
                XDebug.LogError("invalid script func");
                return(false);
            }
            LevelCmdDesc top = _LevelScripts[funcName][0];

            return(top.cmd == LevelCmd.Level_Cmd_TalkL || top.cmd == LevelCmd.Level_Cmd_TalkR);
        }
Example #23
0
    public override bool isWrong(object ob)
    {
        GameObject go = ob as GameObject;

        if (go == null)
        {
            XDebug.LogError("isWrone" + ob.ToString());
            return(true);
        }

        return(false);
    }
Example #24
0
    static void pack_all(BuildTarget buildTarget)
    {
        XPack pack = new XPack();

        pack.setInfo(buildTarget);
        try
        {
            System.IO.Directory.Delete(pack.targetDir, true);
        }
        catch (System.Exception e)
        {
            XDebug.LogError(e.Message);
        }

        XDebug.Log("开始打包");

        foreach (var item in instance._packItems)
        {
            if (item.type == XPackItem.XPackType.File)
            {
                string path = item.path;
                pack.pack(path);
            }
            else if (item.type == XPackItem.XPackType.DirFiles)
            {
                pack.packdirfiles(item.path, item.searchPattern, item.searchOption);
            }
            else if (item.type == XPackItem.XPackType.Dir)
            {
                pack.packdir(item.path, item.searchPattern, item.searchOption);
            }
        }

        pack.packluadir("lua/", luaJit);

        AssetBundleManifest manifest = pack.packAll();
        XPackInfo           info     = new XPackInfo();

        info.parseManifest(manifest, pack.targetDir);
        info._version      = version;
        info._firstVersion = version;
        info.saveFile(pack.targetDir + "Assets/version.json");

        XVer ver = new XVer {
            ver = version, ab = pack.getWebDir(webPublishUrl), remoteLogUrl = remoteLogURL, isRemoteLog = isRemoteLog
        };

        ver.saveFile(pack.targetDir + "Assets/ver.json");



        XDebug.Log("打包结束");
    }
Example #25
0
 public static AIRuntimeStatus LogUpdate(XEntity entity, string str, bool b)
 {
     if (b)
     {
         XDebug.LogError(str);
     }
     else
     {
         XDebug.Log(str);
     }
     return(AIRuntimeStatus.Success);
 }
Example #26
0
File: XVer.cs Project: YoMi-w/Slua-
 public bool load(string str)
 {
     try
     {
         Dictionary <string, object> mapConf = MiniJSON.Json.Deserialize(str) as Dictionary <string, object>;
         return(read_dict(mapConf));
     }
     catch (Exception e)
     {
         XDebug.LogError("装载数据错误" + e.Message);
         return(false);
     }
 }
Example #27
0
    // 直接打包
    public bool pack(string res)
    {
        AssetImporter importer = AssetImporter.GetAtPath(res);

        if (importer == null)
        {
            XDebug.LogError("打包错误,地址不存在" + res);
            return(false);
        }
        importer.assetBundleName = res + ".ab";

        return(true);
    }
Example #28
0
    //lua interface
    public bool DetachDocument(string name)
    {
        uint id = XCommon.singleton.XHash(name);

        if (documents != null)
        {
            return(documents.ContainsKey(id));
        }
        else
        {
            XDebug.LogError("not initial for documents with ", name);
            return(false);
        }
    }
 private void ProcessResult(RequestState requestState, UnityWebRequest request, Action <string> OnSuccess, Action <string> OnFailure)
 {
     if (requestState == RequestState.FAILURE)
     {
         XDebug.LogError(request.error, XDebug.Mask.MyWebRequest);
         OnFailure(request.error);
     }
     else if (requestState == RequestState.SUCCESS)
     {
         XDebug.Log("API Response", XDebug.Mask.MyWebRequest, XDebug.Color.Blue);
         XDebug.Log(request.downloadHandler.text, XDebug.Mask.MyWebRequest, XDebug.Color.Blue);
         OnSuccess(request.downloadHandler.text);
     }
 }
Example #30
0
        public override void OnNstPostAwake()
        {
            base.OnNstPostAwake();

            // Remove if this is not on the root
            if (transform != transform.root)
            {
                XDebug.LogError(!XDebug.logErrors ? null :
                                ("Removing '" + typeof(T) + "' from child '" + name + "' of gameobject " + transform.root.name +
                                 ". This component should only exist on the root of a networked object with a NetworkSyncTranform component."));

                Destroy(this);
            }
        }