示例#1
0
    IEnumerator loadXML()
    {
        string resPath = Path.Combine(Application.streamingAssetsPath, "assetbundle/BundleDict.xml");

        resPath = resPath.Replace('\\', '/');

        resPath = "file://" + resPath;

        UtilLog.Error(resPath);

        UnityWebRequest req = new UnityWebRequest(resPath);

        req.downloadHandler = new DownloadHandlerBuffer();

        yield return(req.SendWebRequest());

        XmlDocument resXml = new XmlDocument();

        resXml.LoadXml(req.downloadHandler.text);

        XmlNode root = resXml.SelectSingleNode("ResMap");

        foreach (var v in root)
        {
            XmlElement elm        = (XmlElement)v;
            string     resPathStr = elm.GetAttribute("ResPath");
            string     abName     = elm.GetAttribute("AbName");

            resAbNameDict[resPathStr] = Path.Combine(Application.streamingAssetsPath, "assetbundle/" + abName);
            resAbNameDict[resPathStr] = resAbNameDict[resPathStr].Replace("\\", "/");
            UtilLog.Error("资源" + resPathStr + " " + resAbNameDict[resPathStr]);
        }

        isXmLLoaded = true;
    }
示例#2
0
 static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     if (e != null && e.Exception != null)
     {
         UtilMessage.ShowError(e.Exception);
         UtilLog.Error(e.Exception);
     }
 }
示例#3
0
    private string getAbName(string resPath)
    {
        if (resAbNameDict.ContainsKey(resPath) == false)
        {
            UtilLog.Error(" Cannot find abName " + resPath);
            return("");
        }

        return(resAbNameDict[resPath]);
    }
示例#4
0
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (e != null && e.ExceptionObject != null)
            {
                Exception exception = e.ExceptionObject as Exception;

                if (exception != null)
                {
                    UtilMessage.ShowError(exception);
                    UtilLog.Error(exception);
                }
            }
        }
示例#5
0
 private void UpdateSoftBinListBox()
 {
     try
     {
         foreach (Bin softbin in gv_softbins.Values)
         {
             lstSoftBins.Items.Add(softbin.Name + ": " + softbin.Qty);
         }
     }
     catch (Exception ex)
     {
         UtilLog.Error(ex);
     }
 }
示例#6
0
    public void LoadAsset <T>(string resPath, Action <UnityEngine.Object, string> loadCallBack) where T : UnityEngine.Object
    {
        T obj = AssetDatabase.LoadAssetAtPath <T>(resPath);

        if (obj == null)
        {
            UtilLog.Error("Load Asset Is Null: " + resPath);
            return;
        }
        if (loadCallBack != null)
        {
            loadCallBack(obj, resPath);
        }
    }
示例#7
0
    public void SetUITexture(GameObject obj, string resPath)
    {
        LoadAsset <Texture2D>(resPath, (UnityEngine.Object loadObj, string path) =>
        {
            Texture2D tex = (Texture2D)loadObj;
            tex.name      = path;
            Sprite sp     = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
            sp.name       = path;
            obj.GetComponent <Image>().sprite = sp;

            UtilLog.Error(obj.GetComponent <Image>().sprite.texture.name);
        },
                              ResEnum.Texture2D
                              );
    }
示例#8
0
 private void btnShowSecsGem_Click(object sender, EventArgs e)
 {
     try
     {
         gv_machine.HandlerIp   = txtHandlerIP.Text.Trim();
         gv_machine.HandlerPort = int.Parse(txtHandlerPort.Text.Trim());
         UtilLog.Info("IP = " + gv_machine.HandlerIp + "; Port = " + gv_machine.HandlerPort);
         MidMsgTransferModule.UpdateSecsGem(gv_machine);
         UtilMessage.ShowInfo("Secs/gem config Update Success!");
     }
     catch (Exception ex)
     {
         UtilLog.Error(ex);
     }
 }
示例#9
0
    public void LoadAssetAsync <T>(string resPath, Action <UnityEngine.Object, string> loadCallBack) where T : UnityEngine.Object
    {
        T obj = AssetDatabase.LoadAssetAtPath <T>(resPath);

        if (obj == null)
        {
            UtilLog.Error("Load Asset Is Null: " + resPath);
        }
        this.monoCoroutine.StartCoroutine(AssetLoaderAsync(() =>
        {
            if (loadCallBack != null)
            {
                loadCallBack(obj, resPath);
            }
        }));
    }
示例#10
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                using (TesterRecipe_Service.TesterRecipe_Service ts_rmsService = new TesterRecipe_Service.TesterRecipe_Service())
                {
                    string strDepartment = "";
                    UtilLog.Info("Verify user login :"******"Verify user login Result:" + sVerfiyResult);

                    if (sVerfiyResult.Substring(0, 4) == "True")
                    {
                        if (sVerfiyResult.Length != 8)
                        {
                            strDepartment = sVerfiyResult.Substring(4, 5);
                        }
                        else
                        {
                            strDepartment = "NONE*";
                        }

                        #region Set User Info Data
                        UtilCommonInfo.UserName = txtUserName.Text.Trim();
                        UtilCommonInfo.Password = txtPassword.Text.Trim();
                        UtilCommonInfo.Dept     = strDepartment;
                        #endregion

                        this.DialogResult = DialogResult.OK;
                    }
                    else if (sVerfiyResult.Substring(0, 4) == "miss")
                    {
                        string sMsg = "UserID or PassWord missmatch!用户名或密码不正确!";
                        UtilMessage.ShowError(sMsg);
                        this.DialogResult = DialogResult.None;
                        //return;
                    }
                }
            }
            catch (Exception ex)
            {
                string sMsg = "Remote Host Not Responding!!远端服务器没有响应!";
                UtilMessage.ShowWarn(sMsg);
                UtilLog.Error("LogIn Handle Send Message to Host Error :", ex);
            }
        }
示例#11
0
    public void LoadAsset <T>(string resPath, Action <UnityEngine.Object, string> loadCallBack) where T : UnityEngine.Object
    {
#if NotAdLoad
        T obj = UnityEditor.AssetDatabase.LoadAssetAtPath <T>(resPath);
        if (obj == null)
        {
            UtilLog.Error("Load Asset Is Null: " + resPath);
            return;
        }
        if (loadCallBack != null)
        {
            loadCallBack(obj, resPath);
        }
#else
        AssetBundlManager.Instance.LoadAsset <T>(resPath, loadCallBack);
#endif
    }
示例#12
0
    public void LoadAsset <T>(string resPath, Action <UnityEngine.Object, string> loadedCallBack) where T : UnityEngine.Object
    {
        string abName = getAbName(resPath);

        if (abName == "")
        {
            return;
        }
        AssetBundle ab = null;

        if (abDict.ContainsKey(abName))
        {
            ab = abDict[abName];
        }
        else
        {
            ab = AssetBundle.LoadFromFile(abName);
        }

        if (ab == null)
        {
            UtilLog.Error("Load AssetBundle Is Null: " + abName);
            return;
        }

        abDict[abName] = ab;

        addAbRef(abName);

        UnityEngine.Object obj = ab.LoadAsset <T>(resPath);

        if (obj == null)
        {
            removeAbRef(abName);
            UtilLog.Error(" AssetBundle " + abName + " cannot find: " + resPath);
            return;
        }


        if (loadedCallBack != null)
        {
            loadedCallBack(obj, resPath);
        }
    }
示例#13
0
    public void LoadAssetAsync <T>(string resPath, Action <UnityEngine.Object, string> loadCallBack) where T : UnityEngine.Object
    {
#if NotAdLoad
        T obj = UnityEditor.AssetDatabase.LoadAssetAtPath <T>(resPath);
        if (obj == null)
        {
            UtilLog.Error("Load Asset Is Null: " + resPath);
        }
        this.monoCoroutine.StartCoroutine(AssetLoaderAsync(() =>
        {
            if (loadCallBack != null)
            {
                loadCallBack(obj, resPath);
            }
        }));
#else
        AssetBundlManager.Instance.LoadAssetAsync <T>(resPath, loadCallBack);
#endif
    }
示例#14
0
    IEnumerator loadAb(string resPath, Action <UnityEngine.Object, string> loadCallBack)
    {
        string abName = getAbName(resPath);

        AssetBundle ab = null;

        if (abDict.ContainsKey(abName))
        {
            ab = abDict[abName];
        }
        else
        {
            UnityWebRequest www = UnityWebRequest.GetAssetBundle(abName, 0);
            yield return(www.SendWebRequest());

            ab = DownloadHandlerAssetBundle.GetContent(www);
        }

        if (ab == null)
        {
            UtilLog.Error("Load AssetBundle Is Null: " + abName);
        }

        abDict[abName] = ab;
        addAbRef(abName);

        UnityEngine.Object obj = ab.LoadAsset <UnityEngine.Object>(resPath);

        if (obj == null)
        {
            removeAbRef(abName);
            UtilLog.Error(" AssetBundle " + abName + " cannot find: " + resPath);
        }
        else
        {
            if (loadCallBack != null)
            {
                loadCallBack(obj, resPath);
            }
        }
    }
示例#15
0
    private void removeAbRef(string abName)
    {
        if (abRefDict.ContainsKey(abName) == false)
        {
            abRefDict[abName] = 0;
        }
        else
        {
            abRefDict[abName] = abRefDict[abName] - 1;
        }

        if (abRefDict[abName] <= 0 && abDict.ContainsKey(abName))
        {
            if (abDict[abName] != null)
            {
                UtilLog.Error(abName);
                abDict[abName].Unload(false);
                abDict[abName] = null;
            }
        }
    }
示例#16
0
        /// <summary>
        /// ftp文件上传
        /// </summary>
        /// <param name="filename">文件名称</param>
        /// <param name="remotefile">远程文件名,含相对路径。不能使用绝对路径。</param>
        /// <returns>是否上传成功</returns>
        public bool Upload(string filename, string remotefile = "")
        {
            bool     is_ok   = false;
            FileInfo fileInf = new FileInfo(filename);
            string   uri     = ftpURI + (string.IsNullOrWhiteSpace(remotefile) ? fileInf.Name : Path.Combine(remotefile, fileInf.Name)); //没有指定时,用文件名。否则用指定的文件名,含相对路径

            ftplog.Info("上传文件路径:" + uri);
            FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));

            reqFTP.Credentials   = new NetworkCredential(ftpUserID, ftpPassword);
            reqFTP.KeepAlive     = KeepAlive;
            reqFTP.Method        = WebRequestMethods.Ftp.UploadFile;
            reqFTP.UseBinary     = UseBinary;
            reqFTP.UsePassive    = PassiveMode; //vsftpd对这个返回不正常,只能false
            reqFTP.ContentLength = fileInf.Length;
            int buffLength = 2048;

            //int buffLength = (int)fileInf.Length;
            byte[]     buff = new byte[buffLength];
            int        contentLen;
            FileStream fs = fileInf.OpenRead();

            try
            {
                Stream strm = reqFTP.GetRequestStream();
                contentLen = fs.Read(buff, 0, buffLength);
                while (contentLen != 0)
                {
                    strm.Write(buff, 0, contentLen);
                    contentLen = fs.Read(buff, 0, buffLength);
                }
                strm.Close();
                fs.Close();
                is_ok = true;
            }
            catch (Exception ex)
            {
                ftplog.Error("ftp上传文件失败:" + ex.Message);
            }
            return(is_ok);
        }
示例#17
0
        private void LoadLotInfo()
        {
            try
            {
                string iniFilePath = Application.StartupPath + "\\config\\LotInfo.ini";
                iniFile = new UtilIniFile(iniFilePath);

                foreach (Bin bin in hardBins)
                {
                    bin.Qty = iniFile.ReadInt("HardBin", bin.Name);

                    if (bin.Qty > 0)
                    {
                        ((TextBox)(this.Controls.Find("txt" + bin.Name, true)[0])).Text = bin.Qty.ToString();
                        gHardBins.Add(bin.Name, bin);
                    }
                }

                //soft bin data
                for (int i = 1; i <= 30; i++)
                {
                    int binQty = iniFile.ReadInt("SoftBin", "SoftBin" + i);

                    if (binQty > 0)
                    {
                        Bin bin = new Bin();
                        bin.Name = "SoftBin" + i;
                        bin.Qty  = binQty;
                        softBins.Add(bin);
                        gSoftBins.Add(bin.Name, bin);
                    }
                }
            }
            catch (Exception ex)
            {
                UtilLog.Error(ex);
            }
        }
示例#18
0
        public static List <Bin> readStatecList(string filePath, string fileName)
        {
            List <Bin>   softBins = new List <Bin>();
            string       testStart = "", testEnd = "", totalTestCount = "", totalGoodCount = "";
            int          intRowCount      = 0;
            bool         boolFoundSoftBin = false;
            FileStream   fileStream       = null;
            StreamReader reader           = null;

            try
            {
                fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Delete);
                reader     = new StreamReader(fileStream);
                string ln = null;

                #region 解析文件
                while ((ln = reader.ReadLine()) != null)
                {
                    ln = ln.Trim();
                    if (ln.StartsWith("Total Test Count"))
                    {
                        totalTestCount = ln.Substring(ln.IndexOf(":") + 1).Trim();
                        continue;
                    }

                    if (ln.StartsWith("Total Good Count"))
                    {
                        totalGoodCount = ln.Substring(ln.IndexOf(":") + 1).Trim();
                        continue;
                    }

                    if (ln.StartsWith("Test Start"))
                    {
                        ln        = ln.Replace(".......", ":");
                        testStart = ln.Substring(ln.IndexOf(":") + 1).Trim();
                        testStart = testStart.Replace("   ", " ");
                        continue;
                    }

                    if (ln.StartsWith("Test End"))
                    {
                        ln      = ln.Replace(".......", ":");
                        testEnd = ln.Substring(ln.IndexOf(":") + 1).Trim();
                        testEnd = testEnd.Replace("   ", " ");
                        continue;
                    }

                    if (ln.Contains("<< TEST  BIN  REPORT >>"))
                    {
                        boolFoundSoftBin = true;
                        intRowCount++;
                        continue;
                    }

                    if (boolFoundSoftBin)
                    {
                        intRowCount++;
                        if (intRowCount > 4)
                        {
                            if (ln.Length < 3)
                            {
                                break;
                            }

                            ln = UtilString.HandleSpace(ln, "_");
                            string[] strArray = ln.Split('_');

                            for (int i = 0; i < strArray.Length / 3; i++)
                            {
                                int rejectQty = int.Parse(strArray[i * 3 + 1]);
                                if (rejectQty > 0)
                                {
                                    Bin bin = new Bin();
                                    //bin.BinNumber = int.Parse(strArray[i * 3]);
                                    bin.Name = "SoftBin" + strArray[i * 3];
                                    bin.Qty  = rejectQty;
                                    softBins.Add(bin);
                                    UtilLog.Info("Test Logger Name: " + fileName + ", " + bin.Name + ", Bin Qty: " + bin.Qty);
                                }
                            }
                        }
                    }
                }
                #endregion
            }
            catch (IOException e)
            {
                UtilLog.Error("Handle Read File IOErr :", e);
            }
            catch (Exception ex)
            {
                UtilLog.Error("Handle Read File Err :", ex);
            }
            finally
            {
                try
                {
                    if (reader != null)
                    {
                        reader.Close();
                        reader.Dispose();
                        reader = null;
                    }
                    if (fileStream != null)
                    {
                        fileStream.Close();
                        fileStream.Dispose();
                        fileStream = null;
                    }
                }
                catch (IOException e)
                {
                    throw (e);
                }
            }

            return(softBins);
        }
示例#19
0
    public static void BeginBuilder()
    {
        ////MonoCoroutine.Instantiate.
        allFileList.Clear();
        depCountDict.Clear();
        GetAllSubResFiles(resDir, allFileList);

        int count = allFileList.Count;

        for (int i = 0; i < count; i++)
        {
            string[] depList  = AssetDatabase.GetDependencies(allFileList[i]);
            int      depCount = depList.Length;
            //UtilLog.Error(" 当前文件 " + allFileList[i] + " ========================== ");
            for (int j = 0; j < depCount; j++)
            {
                if (FileIsResource(depList[j]) && string.Equals(depList[j], allFileList[i]) == false)
                {
                    if (IsAlatsSprite(depList[j]) && IsSpriteAltas(allFileList[i]))
                    {
                        if (depCountDict.ContainsKey(depList[j]))
                        {
                            UtilLog.Error("图片" + depList[j] + "同时在两个图集里面:" + depCountDict[depList[j]][0] + " " + allFileList[i]);
                        }
                        else
                        {
                            depCountDict[depList[j]] = new List <string>();
                            depCountDict[depList[j]].Insert(0, allFileList[i]);
                        }
                    }
                    else if (IsAlatsSprite(depList[j]) == false)
                    {
                        //UtilLog.Error(" 依赖的文件 " + depList[j]);
                        if (depCountDict.ContainsKey(depList[j]))
                        {
                            depCountDict[depList[j]].Insert(0, allFileList[i]);
                        }
                        else
                        {
                            depCountDict[depList[j]] = new List <string>();
                            depCountDict[depList[j]].Insert(0, allFileList[i]);
                        }
                    }
                }
            }
        }

        XmlDocument abDict = new XmlDocument();
        XmlElement  dict   = abDict.CreateElement("ResMap");

        for (int i = 0; i < count; i++)
        {
            AssetImporter importer = AssetImporter.GetAtPath(allFileList[i]);
            if (depCountDict.ContainsKey(allFileList[i]))
            {
                int depCount = depCountDict[allFileList[i]].Count;
                if (depCount == 1)
                {
                    importer.assetBundleName = string.Concat(depCountDict[allFileList[i]][0], ".unity3d");
                }
                else
                {
                    importer.assetBundleName = string.Concat(allFileList[i], ".unity3d");
                }
            }
            else
            {
                importer.assetBundleName = string.Concat(allFileList[i], ".unity3d");
            }
            importer.assetBundleName = importer.assetBundleName.Replace("/", ".");
            XmlElement element = abDict.CreateElement("Res");
            element.SetAttribute("ResPath", allFileList[i]);
            element.SetAttribute("AbName", importer.assetBundleName);

            dict.AppendChild(element);
        }
        abDict.AppendChild(dict);
        UtilLog.Error(Application.streamingAssetsPath);
        string path = Application.streamingAssetsPath + "/AssetBundle/BundleDict.xml";

        path = path.Replace("/", "//");
        UtilLog.Error(path);
        abDict.Save(path);
        AssetDatabase.Refresh();
        BuildPipeline.BuildAssetBundles("Assets/StreamingAssets/AssetBundle", BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneWindows);
    }
示例#20
0
        public static Hashtable readEAGLEFile(string filePath, string fileName)
        {
            System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex(@"^\d+$");
            Hashtable    softBins = new Hashtable();
            string       testStart = "", testEnd = "";
            int          intRowCount = 0;
            bool         boolStart   = false;
            FileStream   fileStream  = null;
            StreamReader reader      = null;

            try
            {
                fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Delete);
                reader     = new StreamReader(fileStream);
                string ln = null;

                #region 解析文件
                while ((ln = reader.ReadLine()) != null)
                {
                    ln = ln.Trim();

                    if (ln.Contains("Data Collection Start Date"))
                    {
                        testStart = ln.Substring(ln.IndexOf(":") + 1).Trim();
                        continue;
                    }
                    if (ln.Contains(("Data Collection Stop  Date")))
                    {
                        testEnd = ln.Substring(ln.IndexOf(":") + 1).Trim();
                        continue;
                    }

                    if (ln.Contains("Sfwr"))
                    {
                        boolStart = true;
                        intRowCount++;
                        continue;
                    }

                    if (boolStart)
                    {
                        intRowCount++;
                        if (intRowCount > 3)
                        {
                            ln = UtilString.HandleSpace(ln, ";");

                            string[] strArray = ln.Split(';');

                            if (strArray.Length < 2)
                            {
                                continue;
                            }

                            if (rex.IsMatch(strArray[strArray.Length - 3]))
                            {
                                Bin bin = new Bin();
                                bin.Name = "SoftBin" + strArray[0];
                                bin.Qty  = int.Parse(strArray[strArray.Length - 3]);
                                softBins.Add(bin.Name, bin);
                            }
                        }
                    }

                    if (ln.Contains("Hdwr"))
                    {
                        break;
                    }
                }
                #endregion
            }
            catch (IOException e)
            {
                UtilLog.Error("Handle Read File IOErr :", e);
            }
            catch (Exception ex)
            {
                UtilLog.Error("Handle Read File Err :", ex);
            }
            finally
            {
                try
                {
                    if (reader != null)
                    {
                        reader.Close();
                        reader.Dispose();
                        reader = null;
                    }
                    if (fileStream != null)
                    {
                        fileStream.Close();
                        fileStream.Dispose();
                        fileStream = null;
                    }
                }
                catch (IOException e)
                {
                    throw (e);
                }
            }
            return(softBins);
        }