Ejemplo n.º 1
0
        /// <summary>
        /// Serves as a hash function for a <see cref="Binding"/> object.
        /// </summary>
        /// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a
        /// hash table.</returns>
        public override int GetHashCode()
        {
            int targetHash = Target == null ? 0 : Target.GetHashCode();
            int sourceHash = Source == null ? 0 : Source.GetHashCode();

            return(targetHash ^ TargetPath.GetHashCode() ^ sourceHash ^ SourcePath.GetHashCode());
        }
Ejemplo n.º 2
0
 public override void ApplyBind()
 {
     if (Target is DependencyObject dpo)
     {
         dpo.DependencyPropertyChanged += Dpo_DependencyPropertyChanged;
         if (Model == BindingMode.TwoWay)
         {
             var dpotValue = TargetPath.GetValueFromSteptSub(Target, 1);//倒数第二层
             if (dpotValue == null)
             {
                 throw new ArgumentException("绑定目标属性为空");
             }
             if (dpotValue is DependencyObject dpotDpValue)
             {
                 bindDp = dpotDpValue;
                 bindDp.DependencyPropertyChanged += Sdpo_DependencyPropertyChanged;//双向绑定监视属性
             }
         }
     }
     else
     {
         throw new ArgumentException("Target必须要继承于DependencyObject");
     }
     base.ApplyBind();
 }
Ejemplo n.º 3
0
        public bool Compatible(PathMatch match) // The specified match is compatible with (does not contradicts to) this match
        {
            // Main rule: if a coverage condition holds for one path (in one or another direction) then it must hold for the other path (in the same direction)

            // SourcePath -> TargetPath
            if (match.SourcePath.StartsWith(SourcePath))         // The specified match continues this path
            {
                return(match.TargetPath.StartsWith(TargetPath)); // The same must be true for the other paths
            }
            else if (SourcePath.StartsWith(match.SourcePath))    // Opposite
            {
                return(TargetPath.StartsWith(match.TargetPath)); // The same must be true for the other paths
            }

            // TargetPath -> SourcePath
            if (match.TargetPath.StartsWith(TargetPath))
            {
                return(match.SourcePath.StartsWith(SourcePath));
            }
            else if (TargetPath.StartsWith(match.TargetPath))
            {
                return(SourcePath.StartsWith(match.SourcePath));
            }

            // Neither source path nor target paths cover.
            // This means they have some intersection (meet table they both continue).
            // This meet point defines an implicit match which we do not check but it might contradict to other matches.

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Expands the given macro.
        /// </summary>
        /// <param name="macro">The macro to expand.</param>
        /// <returns>
        /// The expanded macro.
        /// </returns>
        /// <exception cref="BuildException">
        ///   <para>The macro is not supported.</para>
        ///   <para>-or-</para>
        ///   <para>The macro is not implemented.</para>
        ///   <para>-or-</para>
        ///   <para>The macro cannot be expanded.</para>
        /// </exception>
        /// <exception cref="NotImplementedException">
        ///   <para>Expansion of a given macro is not yet implemented.</para>
        /// </exception>
        protected internal override string ExpandMacro(string macro)
        {
            // perform case-insensitive expansion of macros
            switch (macro.ToLower(CultureInfo.InvariantCulture))
            {
            case "targetname":     // E.g. WindowsApplication1
                return(Path.GetFileNameWithoutExtension(Path.GetFileName(
                                                            TargetPath)));

            case "targetpath":     // E.g. C:\Doc...\Visual Studio Projects\WindowsApplications1\bin\Debug\WindowsApplications1.exe
                return(TargetPath);

            case "targetext":     // E.g. .exe
                return(Path.GetExtension(TargetPath));

            case "targetfilename":     // E.g. WindowsApplications1.exe
                return(Path.GetFileName(TargetPath));

            case "targetdir":     // E.g. C:\Doc...\Visual Studio Projects\WindowsApplications1\bin\Debug
                return(Path.GetDirectoryName(TargetPath) + (TargetPath.EndsWith(
                                                                Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture))
                        ? string.Empty : Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture)));

            default:
                return(base.ExpandMacro(macro));
            }
        }
Ejemplo n.º 5
0
    void BuildUnitPath()     // создание точек движения и вектора вращения для юнита, на основе найденного пути
    {
        TargetPath p = new TargetPath();

        pathTarget = new List <TargetPath>();
        Vector3 directionLast = (path[0].transform.position - target.position).normalized;

        p.direction = directionLast;
        p.position  = NormalizeVector(target.position);
        pathTarget.Add(p);

        if (end.target != null)
        {
            path.RemoveAt(path.Count - 1);
        }

        for (int i = 0; i < path.Count; i++)
        {
            int     id        = (i + 1 < path.Count - 1) ? i + 1 : path.Count - 1;
            Vector3 direction = (path[id].transform.position - path[i].transform.position).normalized;

            if (direction != directionLast)
            {
                p           = new TargetPath();
                p.direction = (i < path.Count - 1) ? direction : directionLast;
                p.position  = NormalizeVector(path[i].transform.position);
                pathTarget.Add(p);
            }

            directionLast = direction;
        }
    }
 public bool ReadFromPath(TargetPath path, ref JToken value, int depth)
 {
     if (depth == path.PathParts.Length && X.HasValue && Y.HasValue && Z.HasValue)
     {
         var oValue = (JObject)value;
         oValue.SetOrAdd("x", X.Value);
         oValue.SetOrAdd("y", Y.Value);
         oValue.SetOrAdd("z", Z.Value);
         return(true);
     }
     else if (path.PathParts[depth] == "x" && X.HasValue)
     {
         var vValue = (JValue)value;
         vValue.Value = X.Value;
         return(true);
     }
     else if (path.PathParts[depth] == "y" && Y.HasValue)
     {
         var vValue = (JValue)value;
         vValue.Value = Y.Value;
         return(true);
     }
     else if (path.PathParts[depth] == "z" && Z.HasValue)
     {
         var vValue = (JValue)value;
         vValue.Value = Z.Value;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 手动触发更新目标
        /// </summary>
        internal virtual void UpdateTarget()
        {
            //TargetPath不能为null
            var value = SourcePath.GetValue(source);

            TargetPath.SetValue(GetConvertValue(value));
        }
    static void DoIt()
    {
        if (!System.IO.File.Exists(TestData.config_resource))
        {
            EditorUtility.DisplayDialog("不得行", "找不到" + TestData.config_resource, "咋办喃");
            return;
        }

        if (!System.IO.Directory.Exists(TestData.testResource_path))
        {
            System.IO.Directory.CreateDirectory(TestData.testResource_path);
        }

        string   json = System.IO.File.ReadAllText(TestData.config_resource);
        CopyMaps maps = JsonMapper.ToObject <CopyMaps>(json);

        string home = TargetPath.GetHome();

        for (int i = 0; i < maps.copyMap.Length; i++)
        {
            string source = home + "/.root/" + maps.copyMap[i];
            string dest   = TestData.testResource_path + System.IO.Path.GetFileName(maps.copyMap[i]);
            if (System.IO.File.Exists(source))
            {
                System.IO.File.Copy(source, dest, true);
            }
            else
            {
                EditorUtility.DisplayDialog("搞不定", "文件不存在:" + source, "咋办");
            }
        }
        EditorUtility.DisplayDialog("搞定了", "拷贝完毕", "好了");
    }
Ejemplo n.º 9
0
        protected virtual string FinalizeTargetPath()
        {
            if (TargetPath == null)
            {
                throw new CodeFluentCodeDomProducerException(string.Format("invalidProducerImplementation {0}", GetType().FullName));
            }

            return(!TargetPath.EndsWith(CodeDomProducer.FileExtension) ? TargetPath + CodeDomProducer.FileExtension : TargetPath);
        }
Ejemplo n.º 10
0
 public override int GetHashCode()
 => IconLocation.GetHashCode() ^
 TargetPath.GetHashCode() ^
 Arguments.GetHashCode() ^
 WorkingDirectory.GetHashCode() ^
 WindowStyle.GetHashCode() ^
 WindowStyle.GetHashCode() ^
 Description.GetHashCode() ^
 FullName.GetHashCode();
Ejemplo n.º 11
0
 public string TargetPathFor(params string[] relative)
 {
     return(Path.Combine(
                TargetPath
                .AsArray()
                .Concat(relative)
                .ToArray()
                ));
 }
Ejemplo n.º 12
0
        static void DoIt()
        {
            string[] files = System.IO.Directory.GetFiles("Assets/Doubility3D/CoreData", "*.*", System.IO.SearchOption.AllDirectories);
            files = files.Where(s => s.EndsWith(".mat") || s.EndsWith(".exr") || s.EndsWith(".shader")).ToArray();
            files = Array.ConvertAll <string, string> (files, new Converter <string, string> ((s) => {
                return(s.Replace('\\', '/'));
            }));

            AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
            buildMap [0].assetBundleName = "coreData.bundle";
            buildMap [0].assetNames      = files;

            Dictionary <string, string> dictShaderName2Path = new Dictionary <string, string> ();

            for (int i = 0; i < files.Length; i++)
            {
                if (files [i].EndsWith(".shader"))
                {
                    Shader shader = AssetDatabase.LoadAssetAtPath <Shader> (files [i]);
                    if (dictShaderName2Path.ContainsKey(shader.name))
                    {
                        EditorUtility.DisplayDialog("不得行", "Shader 名字:" + shader.name + "不唯一", "晓得不嘛");
                        return;
                    }
                    dictShaderName2Path.Add(shader.name, files [i]);
                }
            }

            string jsonString = JsonMapper.ToJson(dictShaderName2Path);

            System.IO.File.WriteAllText(ShaderDictionary.Path, jsonString);
            AssetDatabase.Refresh();

            Array.Resize <string> (ref buildMap [0].assetNames, buildMap [0].assetNames.Length + 1);
            buildMap [0].assetNames [buildMap [0].assetNames.Length - 1] = ShaderDictionary.Path;

            if ((EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android) &&
                (EditorUserBuildSettings.activeBuildTarget != BuildTarget.iOS) &&
                (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows) &&
                (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows64))
            {
                EditorUtility.DisplayDialog("不得行", EditorUserBuildSettings.activeBuildTarget.ToString() + "是不支持的平台", "晓得不嘛");
            }

            string outputFolder = TargetPath.GetHome() + "/.coreData/" + TargetPath.GetPath(EditorUserBuildSettings.activeBuildTarget);

            if (!System.IO.Directory.Exists(outputFolder))
            {
                System.IO.Directory.CreateDirectory(outputFolder);
            }
            BuildPipeline.BuildAssetBundles(outputFolder, buildMap, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
            EditorUtility.DisplayDialog("搞定了", "核心数据输出完毕", "好了");

            System.IO.File.Delete(ShaderDictionary.Path);
            AssetDatabase.Refresh();
        }
Ejemplo n.º 13
0
        void ConvertIt()
        {
            string[] files = null;
            if (configData.selectType == 0) {
                Debug.Log (configData.assetRoot + "是文件夹");
                files = Directory.GetFiles (configData.assetRoot, "*.fbx", SearchOption.AllDirectories);
            } else if (configData.selectType == 1) {
                Debug.Log (configData.pathSelect + "是文件夹");
                files = Directory.GetFiles (configData.pathSelect, "*.fbx", SearchOption.AllDirectories);
            } else if (configData.selectType == 2) {
                Debug.Log (configData.pathSelect + "是文件");
                files = new string[] { configData.pathSelect };
            }

            files = Array.ConvertAll<string, string> (files, new Converter<string, string> (getPath));
            Array.Sort<string> (files, new Comparison<string> ((s1, s2) => {
                return string.Compare (s1, s2);
            }));

            if (files != null) {
                // 以目录为单位进行pass
                Dictionary<string, List<string>> dictFiles = new Dictionary<string, List<string>> ();
                foreach (string file in files) {
                    string key = System.IO.Path.GetDirectoryName (file);
                    if (!dictFiles.ContainsKey (key)) {
                        dictFiles [key] = new List<string> ();
                    }
                    dictFiles [key].Add (file);
                }

                string targetFolder = TargetPath.GetHome() + "/.root";
                foreach (var pair in dictFiles) {
                    string targetDir = targetFolder + "/" + pair.Key;
                    if (!System.IO.Directory.Exists (targetDir)) {
                        System.IO.Directory.CreateDirectory (targetDir);
                    }

                    List<string> thisFiles = pair.Value;
                    foreach (string file in thisFiles) {
                        // 过滤
                        if (configData.filterType != 0) {
                            if (filter (file))
                                continue;
                        }

                        // todo:转换文件
                        UnityModelConvert.Convert (ArtWork.path + file, targetDir);
                    }
                }
                Debug.Log ("全部转换完毕");
                ConfigDataFile.Save (configData);
            }
        }
 public void WriteToPath(TargetPath path, JToken value, int depth)
 {
     if (depth == path.PathParts.Length)
     {
         X = value.Value <float>("x");
         Y = value.Value <float>("y");
         Z = value.Value <float>("z");
         W = value.Value <float>("w");
     }
     // else
     // an unrecognized path, do nothing
 }
Ejemplo n.º 15
0
        public virtual void ToJson(JObject json)
        {
            // No super-object

            json["similarity"] = Similarity;

            json["source_path"] = Com.Schema.Utils.CreateJsonFromObject(SourcePath);
            SourcePath.ToJson((JObject)json["source_path"]);

            json["target_path"] = Com.Schema.Utils.CreateJsonFromObject(TargetPath);
            TargetPath.ToJson((JObject)json["target_path"]);
        }
Ejemplo n.º 16
0
        public virtual void FromJson(JObject json, DcSpace ws)
        {
            // No super-object

            Similarity = (double)json["similarity"];

            SourcePath = (ColumnPath)Com.Schema.Utils.CreateObjectFromJson((JObject)json["source_path"]);
            SourcePath.FromJson((JObject)json["source_path"], ws);

            TargetPath = (ColumnPath)Com.Schema.Utils.CreateObjectFromJson((JObject)json["target_path"]);
            TargetPath.FromJson((JObject)json["target_path"], ws);
        }
Ejemplo n.º 17
0
    void UpdateMove()
    {
        if (!move)
        {
            return;
        }

        if (NormalizeVector(pathTarget[index].direction) != NormalizeVector(target.forward))
        {
            // анимация поворота юнита по вектору движения
            target.rotation = Quaternion.Lerp(target.rotation, Quaternion.LookRotation(pathTarget[index].direction), rotationSpeed);
        }
        else if (index < pathTarget.Count - 1)
        {
            // анимация движения к следующей точке
            target.position = Vector3.MoveTowards(target.position, pathTarget[index + 1].position, moveSpeed * Time.deltaTime);
            if (Vector3.Distance(target.position, pathTarget[index + 1].position) < 0.1f)
            {
                target.position = pathTarget[index + 1].position;
                index++;
            }
        }
        else if (pathTarget.Count > 0 && index == pathTarget.Count - 1 && end.target != null && start.isPlayer)
        {
            // если юнита направили на другого юнита, когда он дойдет до него
            // добавляем еще одну точку с текущей позицией и новым направлением, чтобы юнит развернулся "носом" к цели
            TargetPath p = new TargetPath();
            p.direction = (end.target.position - target.position).normalized;
            p.position  = target.position;
            pathTarget.Add(p);
            start.isPlayer = false;
            index++;
        }
        else         // если юнит достиг цели
        {
            if (end.target == null)
            {
                // анимация ожидания
            }
            else
            {
                // анимация атаки
            }

            UpdateNodeState_inst();
            start.isPlayer = false;
            start          = null;
            end            = null;
            hash           = 0;
            move           = false;
        }
    }
Ejemplo n.º 18
0
        /// <summary>
        /// 手动触发更新源,twoWay 通道2
        /// </summary>
        internal virtual void UpdateSource()
        {
            var newValue = TargetPath.GetValue(Target);

            if (SourcePath == null)
            {
                source = newValue;
            }
            else
            {
                SourcePath.SetValue(GetConvertValue(newValue, true));
            }
        }
 public bool ReadFromPath(TargetPath path, ref JToken value, int depth)
 {
     if (depth == path.PathParts.Length && X.HasValue && Y.HasValue && Z.HasValue && W.HasValue)
     {
         var oValue = (JObject)value;
         oValue.SetOrAdd("x", X.Value);
         oValue.SetOrAdd("y", Y.Value);
         oValue.SetOrAdd("z", Z.Value);
         oValue.SetOrAdd("w", W.Value);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 20
0
        public PackageItem(ITaskItem item)
        {
            OriginalItem  = item;
            SourcePath    = item.GetMetadata("FullPath");
            SourceProject = GetMetadata("MSBuildSourceProjectFile");
            string value = GetMetadata("TargetFramework");

            if (!String.IsNullOrWhiteSpace(value))
            {
                TargetFramework = NuGetFramework.Parse(value);
            }
            TargetPath           = item.GetMetadata(nameof(TargetPath));
            AdditionalProperties = GetMetadata(nameof(AdditionalProperties));
            UndefineProperties   = GetMetadata(nameof(UndefineProperties));
            HarvestedFrom        = GetMetadata(nameof(HarvestedFrom));
            Package        = GetMetadata("PackageId");
            PackageVersion = GetMetadata("PackageVersion");
            IsDll          = Path.GetExtension(SourcePath).Equals(".dll", StringComparison.OrdinalIgnoreCase);
            IsPlaceholder  = NuGetAssetResolver.IsPlaceholder(SourcePath);
            IsRef          = TargetPath.StartsWith("ref/", StringComparison.OrdinalIgnoreCase);

            // determine if we need to append filename to TargetPath
            // see https://docs.nuget.org/create/nuspec-reference#specifying-files-to-include-in-the-package
            // SourcePath specifies file and target specifies file - do nothing
            // SourcePath specifies file and Target specifies directory - copy filename
            // SourcePath specifies wildcard files - copy wildcard
            // SourcePath specifies recursive wildcard - do not allow, recursive directory may impact asset selection
            //   we don't want to attempt to expand the wildcard since the build may not yet be complete.

            if (SourcePath.Contains("**"))
            {
                throw new ArgumentException($"Recursive wildcards \"**\" are not permitted in source paths for packages: {SourcePath}.  Recursive directory may impact asset selection and we don't want to attempt to expand the wildcard since the build may not yet be complete.");
            }

            string sourceFile = Path.GetFileName(SourcePath);

            if (!Path.GetExtension(TargetPath).Equals(Path.GetExtension(sourceFile), StringComparison.OrdinalIgnoreCase) ||
                sourceFile.Contains("*"))
            {
                TargetPath = Path.Combine(TargetPath, sourceFile);
            }

            // standardize to /
            TargetPath = TargetPath.Replace('\\', '/');

            int dirLength = TargetPath.LastIndexOf('/');

            TargetDirectory = (dirLength > 0) ? TargetPath.Substring(0, dirLength) : String.Empty;
        }
Ejemplo n.º 21
0
 public bool Equals(MLTProject pProject)
 {
     return(
         pProject != null &&
         SourceExists.Equals(pProject.SourceExists) &&
         SourceIsValid.Equals(pProject.SourceIsValid) &&
         TargetExists.Equals(pProject.TargetExists) &&
         TargetIsValid.Equals(pProject.TargetIsValid) &&
         TargetName.Equals(pProject.TargetName) &&
         TargetPath.Equals(pProject.TargetPath) &&
         FullPath.Equals(pProject.FullPath) &&
         Job.Equals(pProject.Job) &&
         Name.Equals(pProject.Name) &&
         SourcePath.Equals(pProject.SourcePath));
 }
Ejemplo n.º 22
0
        public override int GetHashCode()
        {
            int hash = 0;

            if (SourcePath != null)
            {
                hash = SourcePath.GetHashCode();
            }

            if (TargetPath != null)
            {
                hash = hash * 4567 + TargetPath.GetHashCode();
            }

            return(hash);
        }
Ejemplo n.º 23
0
        private string GetTargetPlatform()
        {
            if (TargetPlatform == null)
            {
                return(null);
            }

            if (Equals(TargetPlatform, MSBuildTargetPlatform.MSIL))
            {
                return(TargetPath == null || TargetPath.EndsWithOrdinalIgnoreCase(".sln")
                    ? "Any CPU".DoubleQuote()
                    : "AnyCPU");
            }

            return(TargetPlatform.ToString());
        }
    static void DoIt()
    {
        if (!System.IO.File.Exists(TestData.config_path))
        {
            EditorUtility.DisplayDialog("不得行", "找不到" + TestData.config_path, "咋办喃");
            return;
        }

        string output_folder = TestData.testBundle_path + TargetPath.GetPath(EditorUserBuildSettings.activeBuildTarget);

        if (!System.IO.Directory.Exists(output_folder))
        {
            System.IO.Directory.CreateDirectory(output_folder);
        }

        string    json = System.IO.File.ReadAllText(TestData.config_path);
        BuildMaps maps = JsonMapper.ToObject <BuildMaps>(json);

        BuildPipeline.BuildAssetBundles(output_folder, maps.buildMap, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
    }
Ejemplo n.º 25
0
        public void BuildCustomShortcut()
        {
            VbsFilePath = VbsFolderPath + ShortcutName + ".vbs";

            File.WriteAllText(VbsFilePath,
                              string.Format(Resources.CustomShortcutVbsTemplate,
                                            ShortcutName.EscapeVba(),
                                            ShortcutItem.ShortcutFileInfo.FullName.EscapeVba(),
                                            TargetPath.QuoteWrap().EscapeVba(),
                                            TargetArguments.EscapeVba(),
                                            ShortcutType,
                                            (int)WindowType
                                            ));

            ShortcutUtils.CreateLnkFile(ShortcutItem.ShortcutFileInfo.FullName, VbsFilePath,
                                        ShortcutName + " shortcut created by TileIconifier",
                                        iconPath: BasicShortcutIcon,
                                        workingDirectory: WorkingFolder
                                        );
        }
        protected virtual void CreateProjectReferences(ModuleDefinition module)
        {
            ICollection <AssemblyNameReference> dependingOnAssemblies = GetAssembliesDependingOn(module);

            this.projectFileManager.CreateReferencesProjectItem(dependingOnAssemblies.Count);

            string assemblyName = module.IsMain ? module.Assembly.Name.Name : Utilities.GetNetmoduleName(module);
            string copiedReferencesSubfolder = assemblyName + "References";
            string referencesPath            = TargetPath.Remove(TargetPath.LastIndexOf(Path.DirectorySeparatorChar)) + Path.DirectorySeparatorChar + copiedReferencesSubfolder;

            ICollection <AssemblyNameReference> filteredDependingOnAssemblies = FilterDependingOnAssemblies(dependingOnAssemblies);
            int assemblyReferenceIndex  = 0;
            SpecialTypeAssembly special = module.IsReferenceAssembly() ? SpecialTypeAssembly.Reference : SpecialTypeAssembly.None;

            foreach (AssemblyNameReference reference in filteredDependingOnAssemblies)
            {
                this.CreateProjectReferenceInternal(module, reference, ref assemblyReferenceIndex, special, referencesPath, copiedReferencesSubfolder);

                assemblyReferenceIndex++;
            }
        }
 public override void WriteToPath(TargetPath path, JToken value, int depth)
 {
     if (depth == path.PathParts.Length)
     {
         X = value.Value <float>("x");
         Y = value.Value <float>("y");
         Z = value.Value <float>("z");
     }
     else if (path.PathParts[depth] == "x")
     {
         X = value.Value <float>();
     }
     else if (path.PathParts[depth] == "y")
     {
         Y = value.Value <float>();
     }
     else if (path.PathParts[depth] == "z")
     {
         Z = value.Value <float>();
     }
     // else
     // an unrecognized path, do nothing
 }
Ejemplo n.º 28
0
        public override void ApplyBind()
        {
            if (Source is DependencyObject dpo)
            {
                if (Model == BindingMode.TwoWay)
                {
                    if (Target is DependencyObject dpot)
                    {
                        var dpotValue = TargetPath.GetValueFromSteptSub(Target, 1);//倒数第二层
                        if (dpotValue == null)
                        {
                            throw new ArgumentException("绑定目标属性为空");
                        }
                        if (dpotValue is DependencyObject dpotDpValue)
                        {
                            bindDp = dpotDpValue;
                            bindDp.DependencyPropertyChanged += Dpot_PropertyChanged;//双向绑定监视属性
                        }
                        else
                        {
                            throw new ArgumentException("绑定目标属性不为依赖属性");
                        }
                    }
                    else
                    {
                        throw new ArgumentException($"双向绑定时,{nameof(Target)}必须是DependencyObject");
                    }
                }

                dpo.DependencyPropertyChanged += Dpo_PropertyChanged;
            }
            else
            {
                throw new ArgumentException($"DependencyBinding应用绑定出错,属性{nameof(Source)}不为DependencyObject");
            }
            base.ApplyBind();
        }
Ejemplo n.º 29
0
    static void DoIt()
    {
        string[] files = System.IO.Directory.GetFiles(ArtWork.path, "*.*", System.IO.SearchOption.AllDirectories);
        files = files.Where(s => s.EndsWith(".tga") || s.EndsWith(".png") || s.EndsWith(".jpg")).ToArray();
        files = Array.ConvertAll <string, string>(files, new Converter <string, string>((s) => { return(s.Replace('\\', '/')); }));

        if ((EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android) &&
            (EditorUserBuildSettings.activeBuildTarget != BuildTarget.iOS) &&
            (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows) &&
            (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows64))
        {
            EditorUtility.DisplayDialog("不得行", EditorUserBuildSettings.activeBuildTarget.ToString() + "是不支持的平台", "晓得不嘛");
        }

        string[] names = files;
        for (int i = 0; i < names.Length; i++)
        {
            Texture2D texture = AssetDatabase.LoadAssetAtPath <Texture2D>(names[i]);

            string path = names[i].Substring(ArtWork.path.Length);
            path = System.IO.Path.GetDirectoryName(path) + "/" + System.IO.Path.GetFileNameWithoutExtension(path);
            path = TargetPath.GetHome() + "/.root/" + path + "." + TargetPath.GetPath(EditorUserBuildSettings.activeBuildTarget).ToLower() + ".texture";

            string folder = System.IO.Path.GetDirectoryName(path);
            if (!System.IO.Directory.Exists(folder))
            {
                System.IO.Directory.CreateDirectory(folder);
            }

            ByteBuffer bb = TextureSaver.Save(texture);
            FileSaver.Save(bb, Schema.Context.Texture, path);
        }

        names = null;
        EditorUtility.DisplayDialog("搞定了", "纹理输出完毕", "好了");
    }
 public void Restore(TargetPath path, int depth)
 {
 }