Example #1
0
 public static void SetDefultRuleObject(RuleObject rule)
 {
     if (rule == null)
     {
         PlayerPrefs.SetString(Pref_defultRuleGuid, "");
     }
     else
     {
         var path = AssetDatabase.GetAssetPath(rule);
         var guid = AssetDatabase.AssetPathToGUID(path);
         PlayerPrefs.SetString(Pref_defultRuleGuid, guid);
     }
 }
Example #2
0
 /// <summary>
 /// 将名字转换(去除标记性字符)
 /// </summary>
 /// <returns></returns>
 public ImgNode Analyzing(RuleObject Rule, string name)
 {
     this.Name           = Rule.AnalySisImgName(name, out source, out type);
     this.customNameType = Rule.nameType;
     this.forceAddress   = Rule.forceAddress;
     //添加后缀
     if (texture != null)
     {
         this.hashImage    = rect.GetHashCode();
         this.texture.name = TextureName;
         //Debug.Log(TextureName);
     }
     return(this);
 }
Example #3
0
 public GroupNodeItem Analyzing(RuleObject Rule, string name)
 {
     string[] areguments = null;
     this.displayName = Rule.AnalysisGroupName(name, out data.suffix, out areguments);
     if (layerImporter == null)
     {
         layerImporter = Rule.layerImports.Where(x => x.Suffix == data.suffix).FirstOrDefault();
         if (layerImporter == null)
         {
             layerImporter = ScriptableObject.CreateInstance <UGUI.PanelLayerImport>();
         }
     }
     layerImporter.AnalysisAreguments(data, areguments);
     return(this);
 }
Example #4
0
        public GroupNode Analyzing(RuleObject Rule, string name)
        {
            string[] areguments = null;
            this.displayName = Rule.AnalysisGroupName(name, out groupType, out areguments);
            switch (groupType)
            {
            case GroupType.GRID:
                if (areguments != null && areguments.Length > 1)
                {
                    var key = areguments[0];
                    direction = RuleObject.GetDirectionByKey(key);
                }
                if (areguments != null && areguments.Length > 2)
                {
                    var key = areguments[1];
                    constraintCount = int.Parse(key);
                }
                break;

            case GroupType.SCROLLVIEW:
            case GroupType.SLIDER:
            case GroupType.SCROLLBAR:
                if (areguments != null && areguments.Length > 0)
                {
                    var key = areguments[0];
                    direction = RuleObject.GetDirectionByKey(key);
                }
                break;

            case GroupType.GROUP:
                if (areguments != null && areguments.Length > 1)
                {
                    var key = areguments[0];
                    direction = RuleObject.GetDirectionByKey(key);
                }
                if (areguments != null && areguments.Length > 2)
                {
                    var key = areguments[1];
                    spacing = float.Parse(key);
                }
                break;

            default:
                break;
            }
            return(this);
        }
Example #5
0
 public static Texture GetPreviewIcon(PreviewItem item, RuleObject rule)
 {
     RuleObj = rule;
     if (rule == null || item.layerType != LayerType.Group)
     {
         return(previewIcons[item.layerType.ToString()]);
     }
     else
     {
         string   groupType = PSDUnityConst.emptySuffix;
         string[] args;
         rule.AnalysisGroupName(item.name, out groupType, out args);
         if (!previewIcons.ContainsKey(groupType))
         {
             previewIcons[groupType] = LoadTexture(groupType);
         }
         return(previewIcons[groupType]);
     }
 }
Example #6
0
        public static bool IsGlobleRule(RuleObject rule)
        {
            if (!PlayerPrefs.HasKey(Pref_defultRuleGuid))
            {
                return(false);
            }
            if (rule == null)
            {
                return(false);
            }
            var path = AssetDatabase.GetAssetPath(rule);

            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }
            var guid = AssetDatabase.AssetPathToGUID(path);

            if (string.IsNullOrEmpty(guid))
            {
                return(false);
            }
            return(PlayerPrefs.GetString(Pref_defultRuleGuid) == guid);
        }
Example #7
0
        public static void LoadImageImports(RuleObject target, UnityAction onComplete)
        {
            var types = new List <Type>()
            {
                typeof(UGUI.TextImport),
                typeof(UGUI.ImageRawImageImport),
            };

            var assetPath = AssetDatabase.GetAssetPath(target);

            if (string.IsNullOrEmpty(assetPath))
            {
                Debug.Log("Dely LoadImageImports:" + target);
                DelyAcceptObject(target, (x) => LoadImageImports(target, onComplete));
                return;
            }
            Debug.Log("LoadImageImports");
            foreach (var layerType in types)
            {
                var ruleObj = target;

                var importer = ruleObj.imageImports.Find(x => x != null && x.GetType() == layerType);

                if (importer != null && string.IsNullOrEmpty(AssetDatabase.GetAssetPath(importer)))
                {
                    ruleObj.imageImports.Remove(importer);
                }

                if (importer == null)
                {
                    if (string.IsNullOrEmpty(assetPath))
                    {
                        importer = ScriptableObject.CreateInstance(layerType) as UGUI.ImageImport;
                        Debug.Log("create instence:" + layerType.Name);
                        importer.name = layerType.Name;
                        ruleObj.imageImports.Add(importer);
                    }
                    else
                    {
                        var oldItems = AssetDatabase.LoadAllAssetsAtPath(assetPath);
                        var oldItem  = oldItems.Where(x => x is UGUI.ImageImport && x.name == layerType.Name).FirstOrDefault();
                        if (oldItem == null)
                        {
                            importer      = ScriptableObject.CreateInstance(layerType) as UGUI.ImageImport;
                            importer.name = layerType.Name;
                            Debug.Log("add new:" + layerType.Name);
                            AssetDatabase.AddObjectToAsset(importer, assetPath);
                            ruleObj.imageImports.Add(importer);
                        }
                        else
                        {
                            ruleObj.imageImports.Add(oldItem as UGUI.ImageImport);
                            //Debug.Log(oldItem);
                        }
                    }
                }
                else
                {
                    //Debug.Log(importer);
                }
            }

            if (onComplete != null)
            {
                onComplete.Invoke();
            }

            if (string.IsNullOrEmpty(assetPath))
            {
                return;
            }
            AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
        }
Example #8
0
        public static void LoadLayerImports(RuleObject target)
        {
            var assetPath = AssetDatabase.GetAssetPath(target);

            if (string.IsNullOrEmpty(assetPath))
            {
                Debug.Log("Dely LoadLayerImports:" + target);
                DelyAcceptObject(target, (x) => LoadLayerImports(x as RuleObject));
                return;
            }
            Debug.Log("LoadLayerImports");
            var types = AnalysisUtility.layerImportTypes;

            foreach (var layerType in types)
            {
                var ruleObj = target;

                var importer = ruleObj.layerImports.Find(x => x != null && x.GetType() == layerType);

                if (importer != null && string.IsNullOrEmpty(AssetDatabase.GetAssetPath(importer)))
                {
                    ruleObj.layerImports.Remove(importer);
                }

                if (importer == null)
                {
                    if (string.IsNullOrEmpty(assetPath))
                    {
                        importer = ScriptableObject.CreateInstance(layerType) as UGUI.LayerImport;
                        Debug.Log("create instence:" + layerType.Name);
                        importer.name = layerType.Name;
                        ruleObj.layerImports.Add(importer);
                    }
                    else
                    {
                        var oldItems = AssetDatabase.LoadAllAssetsAtPath(assetPath);
                        var oldItem  = oldItems.Where(x => x is UGUI.LayerImport && x.name == layerType.Name).FirstOrDefault();
                        if (oldItem == null)
                        {
                            importer      = ScriptableObject.CreateInstance(layerType) as UGUI.LayerImport;
                            importer.name = layerType.Name;
                            Debug.Log("add new:" + layerType.Name);
                            AssetDatabase.AddObjectToAsset(importer, assetPath);
                            ruleObj.layerImports.Add(importer);
                        }
                        else
                        {
                            ruleObj.layerImports.Add(oldItem as UGUI.LayerImport);
                            //Debug.Log(oldItem);
                        }
                    }
                }
                else
                {
                    //Debug.Log(importer);
                }
            }
            //EditorUtility.SetDirty(ruleObj);
            //AssetDatabase.Refresh();

            if (string.IsNullOrEmpty(assetPath))
            {
                return;
            }
            AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
        }
Example #9
0
 public static void InitEnviroment(RuleObject ruleObj)
 {
     RuleObj = ruleObj;
 }