Ejemplo n.º 1
0
    /** 删除单位 */
    private void deleteElement(SceneElementEditorData data)
    {
        GameObject gameObject = data.gameObject;

        _elementDicByObj.remove(gameObject);
        _elementDic.remove(data.config.instanceID);

        _elementInstanceID = -1;

        try
        {
            GameObject.DestroyImmediate(gameObject);
        }
        catch (Exception e)
        {
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// 生成UI预制
        /// </summary>
        /// <param name="force">是否强制全部生成(如果否,则增量生成,只生成改变量)</param>
        public static void make(bool force = false)
        {
            EditorUtility.DisplayProgressBar("请耐心等待", "正在抽离UI预制体...", 0.0f);

            /** 需要处理的预制体列表 */
            SMap <string, long> generateList = new SMap <string, long>();
            /** 全部预处理列表(包含当前所有的预制体修改记录,用于生成记录文件) */
            SMap <string, long> allGenerateList = new SMap <string, long>();

            if (!Directory.Exists(ShineToolGlobal.uiModelsPath))
            {
                Directory.CreateDirectory(ShineToolGlobal.uiModelsPath);
            }

            if (!Directory.Exists(ShineToolGlobal.uiGenerateModelsPath))
            {
                Directory.CreateDirectory(ShineToolGlobal.uiGenerateModelsPath);
                force = true;
            }

            //生成新预处理列表
            string[] files   = FileUtils.getDeepFileList(ShineToolGlobal.uiModelsPath, "prefab");
            int      pathLen = ShineToolGlobal.gamePath.Length + 1;

            for (int i = 0; i < files.Length; i++)
            {
                string file = files[i];
                long   time = File.GetLastWriteTime(file).Ticks;
                file = file.Substring(pathLen);
                generateList.put(file, time);
                allGenerateList.put(file, time);
            }

            //读取旧预处理列表
            BytesReadStream stream = FileUtils.readFileForBytesReadStream(ShineToolGlobal.uiRecordPath);

            //读取旧预处理列表
            if (force || stream == null || !stream.checkVersion(ShineToolGlobal.uiRecordVersion))
            {
                FileUtils.clearDir(ShineToolGlobal.uiGenerateModelsPath);
            }
            else
            {
                /** 旧预处理列表 */
                SMap <string, long> oldGenerateList = new SMap <string, long>();

                int len = stream.readInt();
                for (int i = 0; i < len; ++i)
                {
                    oldGenerateList[stream.readUTF()] = stream.readLong();
                }

                //比较新旧预制列表,并删除无效预制
                oldGenerateList.forEach((k, v) =>
                {
                    long newTime;
                    string genPath = ShineToolGlobal.uiGenerateModelsPath + "/";
                    if (generateList.tryGetValue(k, out newTime))                //如果新列表里有
                    {
                        if (newTime == oldGenerateList[k])                       //如果未修改,则不用抽离
                        {
                            generateList.remove(k);
                        }
                        else                          //如果已修改
                        {
                            File.Delete(genPath + Path.GetFileName(k));
                        }
                    }
                    else                      //新列表里没有,说明已删除
                    {
                        File.Delete(genPath + Path.GetFileName(k));
                    }
                });
            }

            //生成UI预制
            int progressNum = generateList.length() + 1;
            int curNum      = 0;

            generateList.forEach((k, v) =>
            {
                generateUIPrefab(k);
                ++curNum;
                EditorUtility.DisplayProgressBar("请耐心等待", "正在抽离UI预制体...", (float)curNum / progressNum);
            });

            //写入记录
            BytesWriteStream buffer = new BytesWriteStream();

            buffer.writeVersion(ShineToolGlobal.uiRecordVersion);

            buffer.writeInt(allGenerateList.Count);

            allGenerateList.forEach((k, v) =>
            {
                buffer.writeUTF(k);
                buffer.writeLong(allGenerateList[k]);
            });

            FileUtils.writeFileForBytes(ShineToolGlobal.uiRecordPath, buffer);

            EditorUtility.ClearProgressBar();
        }
Ejemplo n.º 3
0
 /** 移除记录 */
 public void removePath(string path)
 {
     _dic.remove(path);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Map删除
 /// </summary>
 public bool func_MapRemove(TriggerExecutor e, TriggerArg a, SMap <object, object> map, object key)
 {
     return(map.remove(key) != null);
 }