Exemplo n.º 1
0
 private void AutoChargeRule()
 {
     if (exporter.ruleObj == null)
     {
         exporter.ruleObj = RuleHelper.GetRuleObj();
     }
 }
Exemplo n.º 2
0
 private void OnEnable()
 {
     if (autoLoad)
     {
         psdPath = EditorPrefs.GetString(Prefs_pdfPath);
         ruleObj = RuleHelper.GetRuleObj();
     }
 }
Exemplo n.º 3
0
        private void InitReorderLists()
        {
            foreach (var propDic in currentPropertys)
            {
                var key         = propDic.Key;
                var list        = propDic.Value;
                var reorderList = new ReorderableList(list, typeof(SerializedProperty), true, true, false, false);
                reorderList.drawHeaderCallback = (rect) =>
                {
                    var labelRect = new Rect(rect.x, rect.y, rect.width - 60, rect.height);
                    EditorGUI.LabelField(labelRect, key);
                    var resetRect = new Rect(rect.width - 60, rect.y, 60, rect.height);
                    if (GUI.Button(resetRect, "重置", EditorStyles.miniButtonRight))
                    {
                        if (tempObj == null)
                        {
                            tempObj = new SerializedObject(RuleHelper.GetRuleObj());
                        }

                        foreach (var item in currentPropertys[key])
                        {
                            var path     = item.propertyPath;
                            var tempProp = tempObj.FindProperty(path);
                            CopyPropertyValue(item, tempProp);
                        }
                    }
                };
                reorderList.elementHeightCallback = (index) =>
                {
                    var property = currentPropertys[key][index];
                    return(EditorGUI.GetPropertyHeight(property, null, true));
                };
                reorderList.drawElementCallback = (rect, index, isActive, isFocused) =>
                {
                    EditorGUI.PropertyField(rect, currentPropertys[key][index], true);
                };
                reorderLists.Add(reorderList);
            }
        }
Exemplo n.º 4
0
        private void LoadRuleObject()
        {
            var ruleObj = RuleHelper.GetRuleObj();
            var path    = AssetDatabase.GetAssetPath(ruleObj);

            if (string.IsNullOrEmpty(path))
            {
                ruleObj.name = "内嵌规则";
                var assetPath = AssetDatabase.GetAssetPath(target);
                if (!string.IsNullOrEmpty(assetPath))
                {
                    var oldItem = AssetDatabase.LoadAssetAtPath <RuleObject>(assetPath);
                    if (oldItem != null)
                    {
                        //Debug.Log("use old RuleObj:" + target);
                        exporter.ruleObj = oldItem;
                    }
                    else
                    {
                        Debug.Log("Add new rule Object To:" + target);
                        exporter.ruleObj = ruleObj;
                        AssetDatabase.AddObjectToAsset(ruleObj, target);
                        AssetDatabase.Refresh();
                        AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
                        Selection.activeObject = ruleObj;
                    }
                }
                else
                {
                    //exporter.ruleObj = ruleObj;
                }
            }
            else
            {
                exporter.ruleObj = ruleObj;
            }
        }