private void DrawResourceSystem()
        {
            DrbComponent drb = (DrbComponent)target;

            BeginModule("Resource System");
            PathPopup("Editor Path", m_EditorPath);
            if (GUILayout.Button("Open Folder"))
            {
                FolderUtil.OpenFolder(drb.GetPath(m_EditorPath.stringValue));
            }
            PathPopup("Internal Path", m_InternalPath);
            if (GUILayout.Button("Open Folder"))
            {
                FolderUtil.OpenFolder(drb.GetPath(m_InternalPath.stringValue));
            }
            PathPopup("ReadOnly Path", m_ReadOnlyPath);
            if (GUILayout.Button("Open Folder"))
            {
                FolderUtil.OpenFolder(drb.GetPath(m_ReadOnlyPath.stringValue));
            }
            PathPopup("Persistent Path", m_PersistentPath);
            if (GUILayout.Button("Open Folder"))
            {
                FolderUtil.OpenFolder(drb.GetPath(m_PersistentPath.stringValue));
            }
            m_ResourceLoaderComponent.objectReferenceValue = EditorGUILayout.ObjectField("Resource Loader Component", m_ResourceLoaderComponent.objectReferenceValue, typeof(Internal.Resource.ResourceLoaderComponent), true);
            TypePopup("Resource Holder", ref m_ResourceHolderTypeNamesIndex, m_ResourceHolderTypeNames, m_ResourceHolderTypeName);
            TypePopup("Resource Decoder", ref m_ResourceDecoderTypeNamesIndex, m_ResourceDecoderTypeNames, m_ResourceDecoderTypeName);
            TypePopup("Dependency Manifest", ref m_ResourceDependencyManifestTypeNamesIndex, m_ResourceDependencyManifestTypeNames, m_ResourceDependencyManifestTypeName);
            EndModule();
        }
Beispiel #2
0
        private void OnBuildAssetBundleClick()
        {
            int fileCount = IOUtil.GetAllFileCount(m_AssetPath);
            int index     = 0;

            //SaveFolderSettings(new string[] { m_AssetPath }, fileCount, ref index);

            for (int i = 0; i < m_PlatformSelected.Count; ++i)
            {
                string toPath = StringUtil.CombinePath(m_OutputPath, m_PlatformSelected[i].ToString());
                if (!Directory.Exists(toPath))
                {
                    Directory.CreateDirectory(toPath);
                }
                BuildPipeline.BuildAssetBundles(toPath, m_BuildAssetBundleOptions, m_PlatformSelected[i]);
            }

            if (m_Encoder != null)
            {
                fileCount = IOUtil.GetAllFileCount(m_OutputPath);
                index     = 0;
                EncryptAssetBundle(m_OutputPath, fileCount, ref index);
            }
            EditorUtility.ClearProgressBar();
            FolderUtil.OpenFolder(m_OutputPath);
            ShowNotification(new GUIContent("Build Asset Bundles Finish"));
            UnityEngine.Debug.Log("Build Asset Bundles Finish");
        }
Beispiel #3
0
        private void Gen(string path)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            Assembly[]  assemblys = AppDomain.CurrentDomain.GetAssemblies();
            List <Type> types     = new List <Type>();

            for (int i = 0; i < assemblys.Length; ++i)
            {
                try
                {
                    Type[] ts = assemblys[i].GetTypes();
                    types.AddRange(ts);
                }
                catch
                {
                }
            }

            List <Type> extTypes = new List <Type>();

            for (int i = 0; i < types.Count; ++i)
            {
                if (types[i].Name.EndsWith(m_ExtensionsName))
                {
                    extTypes.Add(types[i]);
                }
            }
            float count = types.Count;

            for (int i = 0; i < types.Count; ++i)
            {
                Type t = types[i];
                if (EditorUtility.DisplayCancelableProgressBar("Generating EmmyLua Api", t.FullName, i / count))
                {
                    break;
                }
                Type extType = extTypes.Find((Type temp) => { return(temp.Name.Equals(t.Name + m_ExtensionsName)); });
                if (extType != null && (!extType.IsAbstract || !extType.IsSealed))
                {
                    extType = null;
                }
                GenType(t, extType, false, path);
            }
            EditorUtility.ClearProgressBar();
            FolderUtil.OpenFolder(m_OutputPath);
            UnityEngine.Debug.Log("Generate EmmyLua Api Finish");
        }
        private void OnGUI()
        {
            if (GUILayout.Button("Load Protocol Config"))
            {
                m_ConfigPath = EditorUtility.OpenFilePanel("Select Protocol Config", PlayerPrefs.GetString("ProtocolWindow.ConfigPath", Application.dataPath), "xml");
                if (!string.IsNullOrEmpty(m_ConfigPath))
                {
                    if (File.Exists(m_ConfigPath))
                    {
                        using (FileStream fs = new FileStream(m_ConfigPath, FileMode.Open, FileAccess.Read))
                        {
                            XmlSerializer xmldes = new XmlSerializer(m_Menus.GetType());
                            m_Menus = (List <Menu>)xmldes.Deserialize(fs);
                        }

                        PlayerPrefs.SetString("ProtocolWindow.ConfigPath", m_ConfigPath);
                    }
                }
            }

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.BeginVertical("box", GUILayout.Width(240f));
                {
                    EditorGUILayout.LabelField("Menu");
                    m_ProtocolScrollPos = EditorGUILayout.BeginScrollView(m_ProtocolScrollPos, false, false, GUILayout.Width(240f), GUILayout.Height(360f));
                    {
                        if (m_Menus != null && m_Menus.Count > 0)
                        {
                            for (int i = 0; i < m_Menus.Count; ++i)
                            {
                                Menu menu = m_Menus[i];
                                menu.isFoldout = EditorGUILayout.Foldout(menu.isFoldout, menu.Name, true);
                                if (menu.isFoldout)
                                {
                                    m_CurrentMenu = menu;
                                    for (int j = 0; j < menu.ProtocolInfos.Count; ++j)
                                    {
                                        Protocol protocol = menu.ProtocolInfos[j];
                                        EditorGUILayout.BeginHorizontal();
                                        {
                                            GUILayout.Space(30f);
                                            bool isSelect = EditorGUILayout.ToggleLeft(string.IsNullOrEmpty(protocol.Code) ? "Empty Protocol" : string.Format("({0}){1}", protocol.Code, protocol.CnName), m_CurrentProtocol == protocol);
                                            if (isSelect)
                                            {
                                                if (m_CurrentProtocol != protocol)
                                                {
                                                    m_CurrentProtocol = protocol;
                                                    m_SelectedFields.Clear();
                                                }
                                            }
                                        }
                                        EditorGUILayout.EndHorizontal();
                                    }
                                }
                            }
                        }
                    }
                    EditorGUILayout.EndScrollView();



                    EditorGUILayout.BeginHorizontal();
                    {
                        m_NewName = EditorGUILayout.TextField(m_NewName);
                        if (GUILayout.Button("Add Menu", GUILayout.Width(80f)))
                        {
                            Menu menu = new Menu(DateTime.Now.Ticks, m_NewName);
                            m_Menus.Add(menu);
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    if (GUILayout.Button("Add Protocol"))
                    {
                        if (m_CurrentMenu == null)
                        {
                            UnityEngine.Debug.LogError("please select a menu");
                            return;
                        }
                        Protocol protocol = new Protocol(DateTime.Now.Ticks);
                        m_CurrentMenu.ProtocolInfos.Add(protocol);
                    }

                    if (GUILayout.Button("Delete Menu"))
                    {
                        if (m_CurrentMenu == null)
                        {
                            UnityEngine.Debug.LogError("please select a menu");
                            return;
                        }
                        m_Menus.Remove(m_CurrentMenu);
                        m_CurrentMenu = null;
                    }

                    if (GUILayout.Button("Delete Protocol"))
                    {
                        if (m_CurrentProtocol == null)
                        {
                            UnityEngine.Debug.LogError("please select a protocol");
                            return;
                        }
                        m_CurrentMenu.ProtocolInfos.Remove(m_CurrentProtocol);
                        m_CurrentProtocol = null;
                    }
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical("box", GUILayout.Width(530f));
                {
                    if (m_CurrentProtocol != null)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField("Protocol Name", GUILayout.Width(100f));
                            m_CurrentProtocol.EnName = EditorGUILayout.TextField(m_CurrentProtocol.EnName);
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField("Display Name", GUILayout.Width(100f));
                            m_CurrentProtocol.CnName = EditorGUILayout.TextField(m_CurrentProtocol.CnName);
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField("Description", GUILayout.Width(100f));
                            m_CurrentProtocol.Description = EditorGUILayout.TextField(m_CurrentProtocol.Description);
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField("Protocol Code", GUILayout.Width(100f));
                            m_CurrentProtocol.Code = EditorGUILayout.TextField(m_CurrentProtocol.Code);
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField("Selected", GUILayout.Width(50f));
                            EditorGUILayout.LabelField("Type", GUILayout.Width(50f));
                            EditorGUILayout.LabelField("Name", GUILayout.Width(60f));
                            EditorGUILayout.LabelField("Desc", GUILayout.Width(60f));
                            EditorGUILayout.LabelField("IsLoop", GUILayout.Width(50f));
                            EditorGUILayout.LabelField("ToCondition", GUILayout.Width(80f));
                            EditorGUILayout.LabelField("ToResult", GUILayout.Width(70f));
                            EditorGUILayout.LabelField("ToCustom", GUILayout.Width(70f));
                        }
                        EditorGUILayout.EndHorizontal();

                        m_FieldScrollPos = EditorGUILayout.BeginScrollView(m_FieldScrollPos, false, false, GUILayout.Width(530f), GUILayout.Height(330f));
                        {
                            for (int i = 0; i < m_CurrentProtocol.FieldInfos.Count; ++i)
                            {
                                Field field = m_CurrentProtocol.FieldInfos[i];
                                EditorGUILayout.BeginHorizontal();
                                {
                                    bool isSelected  = m_SelectedFields.Contains(field);
                                    bool newSelected = EditorGUILayout.Toggle(isSelected, GUILayout.Width(50f));
                                    if (isSelected != newSelected)
                                    {
                                        if (newSelected)
                                        {
                                            m_SelectedFields.Add(field);
                                        }
                                        else
                                        {
                                            m_SelectedFields.Remove(field);
                                        }
                                    }

                                    field.Type              = EditorGUILayout.TextField(field.Type, GUILayout.Width(50f));
                                    field.EnName            = EditorGUILayout.TextField(field.EnName, GUILayout.Width(60f));
                                    field.CnName            = EditorGUILayout.TextField(field.CnName, GUILayout.Width(60f));
                                    field.IsLoop            = EditorGUILayout.Toggle(field.IsLoop, GUILayout.Width(50f));
                                    field.AttachToCondition = EditorGUILayout.TextField(field.AttachToCondition, GUILayout.Width(80f));
                                    field.AttachToResult    = EditorGUILayout.IntField(field.AttachToResult, GUILayout.Width(70f));
                                    field.AttachToCustom    = EditorGUILayout.TextField(field.AttachToCustom, GUILayout.Width(70f));
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUILayout.EndScrollView();

                        if (GUILayout.Button("Add Field"))
                        {
                            Field field = new Field();
                            m_CurrentProtocol.FieldInfos.Add(field);
                        }

                        if (GUILayout.Button("Delete Field"))
                        {
                            for (int i = 0; i < m_SelectedFields.Count; ++i)
                            {
                                m_CurrentProtocol.FieldInfos.Remove(m_SelectedFields[i]);
                            }
                            m_SelectedFields.Clear();
                        }
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Save Protocol Config"))
            {
                if (string.IsNullOrEmpty(m_ConfigPath))
                {
                    m_ConfigPath = EditorUtility.SaveFilePanel("Save Protocol Config", Application.dataPath, "ProtocolConfig", "xml");
                }
                if (!string.IsNullOrEmpty(m_ConfigPath))
                {
                    using (FileStream fs = new FileStream(m_ConfigPath, FileMode.Create, FileAccess.Write))
                    {
                        XmlSerializer serializer = new XmlSerializer(m_Menus.GetType());
                        serializer.Serialize(fs, m_Menus);
                    }

                    PlayerPrefs.SetString("ProtocolWindow.ConfigPath", m_ConfigPath);
                }
            }

            EditorGUILayout.BeginHorizontal();
            {
                m_OutputPath = EditorGUILayout.TextField("Output Path", m_OutputPath);
                if (GUILayout.Button("Browse", GUILayout.Width(80f)))
                {
                    string directory = EditorUtility.OpenFolderPanel("Select Output Directory", m_OutputPath, string.Empty);
                    if (!string.IsNullOrEmpty(directory))
                    {
                        m_OutputPath = directory;
                        PlayerPrefs.SetString(OutputPathKey, m_OutputPath);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            int selectedIndex = EditorGUILayout.Popup("Protocol Creater", m_ProtocolCreaterTypeNamesIndex, m_ProtocolCreaterTypeNames.ToArray());

            if (m_ProtocolCreaterTypeNamesIndex != selectedIndex)
            {
                m_ProtocolCreaterTypeNamesIndex = selectedIndex;
                if (m_ProtocolCreaterTypeNamesIndex > 0)
                {
                    Assembly[] assembly = AppDomain.CurrentDomain.GetAssemblies();
                    for (int i = 0; i < assembly.Length; ++i)
                    {
                        Type type = assembly[i].GetType(m_ProtocolCreaterTypeNames[m_ProtocolCreaterTypeNamesIndex]);
                        if (type != null)
                        {
                            m_Creater = (IProtocolCreater)Activator.CreateInstance(type);
                            break;
                        }
                    }
                }
                else
                {
                    m_Creater = null;
                }
            }
            if (m_Creater == null)
            {
                EditorGUILayout.HelpBox("please select a valid protocol creater", MessageType.Error);
            }
            else
            {
                GUILayout.Space(20f);
                if (GUILayout.Button("Generate All Protocol Code"))
                {
                    int count = 0;
                    for (int i = 0; i < m_Menus.Count; ++i)
                    {
                        count += m_Menus[i].ProtocolInfos.Count;
                    }


                    for (int i = 0; i < m_Menus.Count; ++i)
                    {
                        for (int j = 0; j < m_Menus[i].ProtocolInfos.Count; ++j)
                        {
                            EditorUtility.DisplayProgressBar("Generating protocol code", m_Menus[i].Name, (float)(i * j) / count);
                            m_Creater.CreateProtocol(m_Menus[i], m_Menus[i].ProtocolInfos[j], m_OutputPath);
                        }
                    }
                    m_Creater.CreateCodeDef(m_Menus, m_OutputPath);

                    EditorUtility.ClearProgressBar();
                    FolderUtil.OpenFolder(m_OutputPath);
                }
            }
        }
Beispiel #5
0
        private void OnGUI()
        {
            EditorGUILayout.BeginVertical();
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Data Source Search Parttern", GUILayout.Width(170f));
                    string dataSourceSearchParttern = EditorGUILayout.TextField(m_DataSourceSearchParttern);
                    if (!string.IsNullOrEmpty(dataSourceSearchParttern) && !dataSourceSearchParttern.Equals(m_DataSourceSearchParttern))
                    {
                        m_DataSourceSearchParttern = dataSourceSearchParttern;
                        PlayerPrefs.SetString(DataSourceSearchPartternKey, m_DataSourceSearchParttern);
                        if (Directory.Exists(m_DataSourcePath))
                        {
                            m_DataSources = Directory.GetFiles(m_DataSourcePath, m_DataSourceSearchParttern, SearchOption.AllDirectories);
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Data Source Path", GUILayout.Width(110f));
                    m_DataSourcePath = EditorGUILayout.TextField(m_DataSourcePath);
                    if (GUILayout.Button("Browse", GUILayout.Width(80f)))
                    {
                        string directory = EditorUtility.OpenFolderPanel("Select Data Source Directory", m_DataSourcePath, string.Empty);
                        if (!string.IsNullOrEmpty(directory))
                        {
                            m_DataSourcePath = directory;
                            if (Directory.Exists(m_DataSourcePath))
                            {
                                m_DataSources = Directory.GetFiles(m_DataSourcePath, m_DataSourceSearchParttern, SearchOption.AllDirectories);
                                PlayerPrefs.SetString(DataSourcePathKey, m_DataSourcePath);
                            }
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.LabelField("Contains Data Source");
                m_DataScrollPos = EditorGUILayout.BeginScrollView(m_DataScrollPos, true, false, GUILayout.Width(560f), GUILayout.Height(100f));
                {
                    if (m_DataSources != null && m_DataSources.Length > 0)
                    {
                        for (int i = 0; i < m_DataSources.Length; ++i)
                        {
                            EditorGUILayout.LabelField(m_DataSources[i]);
                        }
                    }
                }
                EditorGUILayout.EndScrollView();



                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Output Path", GUILayout.Width(80f));
                    m_OutputPath = EditorGUILayout.TextField(m_OutputPath);
                    if (GUILayout.Button("Browse", GUILayout.Width(80f)))
                    {
                        string directory = EditorUtility.OpenFolderPanel("Select Output Directory", m_OutputPath, string.Empty);
                        if (!string.IsNullOrEmpty(directory))
                        {
                            m_OutputPath = directory;
                            PlayerPrefs.SetString(OutputPathKey, m_OutputPath);
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                int selectedIndex = EditorGUILayout.Popup("Data Table Creater", m_DataTableCreaterTypeNamesIndex, m_DataTableCreaterTypeNames.ToArray());
                if (m_DataTableCreaterTypeNamesIndex != selectedIndex)
                {
                    m_DataTableCreaterTypeNamesIndex = selectedIndex;
                    if (m_DataTableCreaterTypeNamesIndex > 0)
                    {
                        Assembly[] assembly = AppDomain.CurrentDomain.GetAssemblies();
                        for (int i = 0; i < assembly.Length; ++i)
                        {
                            Type type = assembly[i].GetType(m_DataTableCreaterTypeNames[m_DataTableCreaterTypeNamesIndex]);
                            if (type != null)
                            {
                                m_Creater = (IDataTableCreater)Activator.CreateInstance(type);
                                break;
                            }
                        }
                    }
                    else
                    {
                        m_Creater = null;
                    }
                }

                if (m_Creater == null)
                {
                    EditorGUILayout.HelpBox("please select a valid data table creater", MessageType.Error);
                }
                else
                {
                    GUILayout.Space(20f);
                    if (GUILayout.Button("Generate Data Table"))
                    {
                        if (m_DataSources == null || m_DataSources.Length == 0)
                        {
                            UnityEngine.Debug.LogError("please select a valid excel path");
                            return;
                        }
                        if (m_Creater == null)
                        {
                            UnityEngine.Debug.LogError("please select a valid data table creater");
                            return;
                        }
                        for (int i = 0; i < m_DataSources.Length; ++i)
                        {
                            EditorUtility.DisplayProgressBar("Generating Data File", m_DataSources[i], (float)i / m_DataSources.Length);
                            m_Creater.CreateDataTable(m_DataSources[i], m_OutputPath);
                        }
                        EditorUtility.ClearProgressBar();
                        FolderUtil.OpenFolder(m_OutputPath);
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }