コード例 #1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            m_CurRule = (AutoBundle)target;

            DrawAddBtn();

            GUILayout.Space(20);
            m_CurRule.showLog = EditorGUILayout.Toggle(new GUIContent("ShowLog"), m_CurRule.showLog);
            string[] names = GetNames();
            if (names != null && names.Length > 0)
            {
                m_SelectedID = EditorGUILayout.Popup("Sets", m_SelectedID, names);
            }

            DrawDelete();

            DrawSelect();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
            serializedObject.ApplyModifiedProperties();
        }
コード例 #2
0
        public static void CreateAssetRule()
        {
            AutoBundle newRule = AutoBundle.CreateAssetRule();

            string selectionPath = "Assets";

            foreach (Object obj in Selection.GetFiltered(typeof(Object), SelectionMode.Assets))
            {
                selectionPath = AssetDatabase.GetAssetPath(obj);
                if (File.Exists(selectionPath))
                {
                    selectionPath = Path.GetDirectoryName(selectionPath);
                }
                break;
            }

            string newRuleFileName = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(selectionPath, "NewAutoBundle.asset"));

            newRuleFileName = newRuleFileName.Replace("\\", "/");
            AssetDatabase.CreateAsset(newRule, newRuleFileName);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            EditorUtility.FocusProjectWindow();
            Selection.activeObject = newRule;
        }
コード例 #3
0
        /// <summary>
        /// 当前目录查找,然后往上递归
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        static private AutoBundle SearchRecursive(AssetImporter impoter, string path)
        {
            foreach (var findAsset in AssetDatabase.FindAssets("t:AutoBundle", new[] { Path.GetDirectoryName(path) }))
            {
                var p = Path.GetDirectoryName(AssetDatabase.GUIDToAssetPath(findAsset));
                if (p == Path.GetDirectoryName(path))
                {
                    string     setName = string.Empty;
                    AutoBundle rule    = AssetDatabase.LoadAssetAtPath <AutoBundle>(AssetDatabase.GUIDToAssetPath(findAsset));
                    if (rule != null && rule.IsMatch(impoter, out setName))
                    {
                        return(rule);
                    }
                }
            }

            path = Directory.GetParent(path).FullName;
            path = path.Replace('\\', '/');
            path = path.Remove(0, Application.dataPath.Length);
            path = path.Insert(0, "Assets");
            if (path != "Assets")
            {
                return(SearchRecursive(impoter, path));
            }
            return(null);
        }
コード例 #4
0
        public static AutoBundle CreateAssetRule()
        {
            AutoBundle autoBundle = AutoBundle.CreateInstance <AutoBundle>();//(AutoBundle)Activator.CreateInstance(typeof(AutoBundle), true);

            autoBundle.Init();
            return(autoBundle);
        }
コード例 #5
0
        static private void FindRuleAndSet(string path)
        {
            AssetImporter importer = AssetImporter.GetAtPath(path);
            AutoBundle    rule     = FindAutoBundle(importer, importer.assetPath);

            if (rule == null)
            {
                return;
            }
            rule.ApplySettings(importer);
        }