public static void CreateBlendRule() { BlendRule rule = ScriptableObject.CreateInstance <BlendRule>(); rule.Init(); string path = AssetDatabase.GetAssetPath(Selection.activeObject); if (path.Length == 0) { path = "Assets"; } else if (System.IO.Path.GetExtension(path).Length > 0) { path = path.Replace("/" + System.IO.Path.GetFileName(path), ""); } path = AssetDatabase.GenerateUniqueAssetPath(path + "/blendrule.asset"); AssetDatabase.CreateAsset(rule, path); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = rule; }
private void OnEnable() { _blend_rule = (BlendRule)target; //get blend tile selection index _bt_index = EditorPrefs.GetInt(BT_INDEX_KEY, 0); //get rule selection index _rl_index = EditorPrefs.GetInt(RL_INDEX_KEY, -1); //get add blend rule object _config = ScriptableObject.CreateInstance <RuleConfigurationWrapper>(); _config.Init(); _rule_obj = new SerializedObject(_config); _rule_prop = _rule_obj.FindProperty("config"); }