Exemplo n.º 1
0
        void OnGUI()
        {
            EditorGUILayout.BeginVertical();

            GUILayout.Label(mDeviceName.Name);
            mDeviceName.SettingsFile = GUILabelAndTextField("FileName", mDeviceName.SettingsFile);
            GUILayout.Space(10);
            EditorGUILayout.PropertyField(_assetLstProperty, true);
            GUILayout.Space(20);
            if (GUILayout.Button("Add"))
            {
                _serializedObject.ApplyModifiedProperties();
                AddDeviceForSdk.ChangeValue(mDeviceName, path);
                File.WriteAllText(path + mDeviceName.SettingsFile, JsonUtility.ToJson(m_CurrentDeviceSetting, true));
                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();
                this.Close();
            }
            if (GUILayout.Button("CloseAll"))
            {
                CloseAll = true;
            }
            if (CloseAll)
            {
                this.Close();
            }
            EditorGUILayout.EndVertical();
        }
Exemplo n.º 2
0
        static void Open()
        {
            Rect wr = new Rect(0, 0, 700, 1000);


            AddDeviceForSdk frameworkConfigEditorWindow = (AddDeviceForSdk)EditorWindow.GetWindowWithRect(typeof(AddDeviceForSdk), wr, true, "Add Device");

            m_Setting        = new DeviceSettings();
            m_CurrentWindows = frameworkConfigEditorWindow;
            frameworkConfigEditorWindow.Show();
            frameworkConfigEditorWindow.isOpen = false;
        }
Exemplo n.º 3
0
        void OnGUI()
        {
            EditorGUILayout.BeginVertical();
            GUILayout.Space(10);

            GUILayout.Label("Platform");
            Index = EditorGUILayout.Popup(Index, m_Platform);
            GUILayout.Space(10);

            m_Device.Name = GUILabelAndTextField("Device Name", m_Device.Name, true);

            m_Device.SettingsFile = GUILabelAndTextField("File Name", m_Device.SettingsFile, true);

            if (m_Device.SettingsFile != null && !m_Device.SettingsFile.Contains(".txt"))
            {
                m_Device.SettingsFile += ".txt";
            }
            GUILayout.Space(10);

            if (m_Setting == null)
            {
                m_Setting = new DeviceSettings();
            }

            if (_assetLstProperty == null)
            {
                _serializedObject = new SerializedObject(this);
                _assetLstProperty = _serializedObject.FindProperty("ModelsName");
            }

            GUILayout.Label("------------Must Set RealModelName -------------");
            if (_assetLstProperty != null && _serializedObject != null)
            {
                EditorGUILayout.PropertyField(_assetLstProperty, true);
            }
            GUILayout.Label("------------/Must Set RealModelName -------------");

            GUILayout.Label("UIBottom");
            m_Setting.UIBottomOffset = EditorGUILayout.FloatField(m_Setting.UIBottomOffset);//float.Parse(GUILabelAndTextField("UIBottom", m_Setting.UIBottomOffset.ToString(),true));

            GUILayout.Label("UILeft");
            m_Setting.UILeftOffset = EditorGUILayout.FloatField(m_Setting.UILeftOffset);

            GUILayout.Label("UIRight");
            m_Setting.UIRightOffset = EditorGUILayout.FloatField(m_Setting.UIRightOffset);

            GUILayout.Label("UITop");
            m_Setting.UITopOffset = EditorGUILayout.FloatField(m_Setting.UITopOffset);

            GUILayout.Space(10);

            if (GUILayout.Button("Add"))
            {
                if (_assetLstProperty != null && _serializedObject != null)
                {
                    _serializedObject.ApplyModifiedProperties();
                }

                if (m_Device.Name == null || m_Device.Name.Equals(string.Empty))
                {
                    this.ShowNotification(new GUIContent("Name is Null"));
                    return;
                }

                if (m_Device.SettingsFile == null || m_Device.SettingsFile.Equals(string.Empty))
                {
                    this.ShowNotification(new GUIContent("FileName is Null"));
                    return;
                }

                m_Device.Models = new List <string>();
                m_Device.Models.AddRange(ModelsName);

                File.WriteAllText(path + m_Device.SettingsFile, JsonUtility.ToJson(m_Setting, true));
                AddDeviceForSdk.AddValue(m_Device, m_Platform[Index], path);

                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();
            }

            EditorGUILayout.EndVertical();
        }
Exemplo n.º 4
0
        //void OnHierarchyChange()
        //{
        //    this.Close();
        //    this.Show();
        //}

        //void OnProjectChange()
        //{
        //    this.Close();
        //    this.Show();
        //}

        void OnGUI()
        {
            EditorGUILayout.BeginVertical();
            GUI.skin.label.fontSize = 12;

            GUILayout.Space(10);
            GUILayout.Space(10);
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.EndHorizontal();
            //Debug.Log(Application.dataPath);

            ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos, true, false, GUILayout.Width(800), GUILayout.Height(900));

            if (Path == null || Path.Equals(string.Empty))
            {
                UnityEngine.Object tempObj = Selection.activeObject;
                Path = AssetDatabase.GetAssetPath(tempObj);
                if (!Path.Contains("devices"))
                {
                    return;
                }
                StreamReader m_reader = new StreamReader(Path);
                m_Devices = m_reader.ReadToEnd();

                m_CurrentWindows = this;
                EditorFileText   = "pvt_";
                m_CurrentDevices = new Device();
                isOpen           = false;
            }
            if (m_Devices != null && !m_Devices.Equals(string.Empty))
            {
                if (_serializedObject == null)
                {
                    StreamReader m_reader = new StreamReader(Path);
                    m_Devices     = m_reader.ReadToEnd();
                    m_DevicesData = JsonUtility.FromJson <Devices>(m_Devices);

                    List <Device> m_DeviceList = m_DevicesData.Platforms.Find(item => item.Platform.Equals("Android")).Devices;
                    string        temp         = Path;
                    temp = temp.Replace("Assets/", "/");
                    string latPath = Application.dataPath + temp;
                    latPath = latPath.Replace("devices.json", "");

                    DirectoryInfo dir = new DirectoryInfo(latPath);

                    FileInfo[]    allInfo       = dir.GetFiles();
                    List <string> m_HasFileList = new List <string>();

                    for (int i = 0; i < allInfo.Length; i++)
                    {
                        m_HasFileList.Add(allInfo[i].Name);
                    }
                    int index = 0;
                    if (!isOpen)
                    {
                        isOpen = true;
                        for (int i = 0; i < m_DeviceList.Count; i++)
                        {
                            if (!m_HasFileList.Contains(m_DeviceList[i].SettingsFile))
                            {
                                DevicesSettingWindow tempWindows = new DevicesSettingWindow();
                                tempWindows.Open(m_DeviceList[i], latPath);
                                tempWindows.position = new Rect(++index * position.x, position.yMax / 2, 300, 300);
                            }
                        }
                    }

                    _serializedObject = new SerializedObject(this);
                    _assetLstProperty = _serializedObject.FindProperty("m_DevicesData");
                }

                if (_assetLstProperty != null && _serializedObject != null)
                {
                    EditorGUILayout.PropertyField(_assetLstProperty, true);
                }

                //Debug.Log(Path);
            }
            EditorGUILayout.EndScrollView();

            #region 保存

            if (GUILayout.Button("Apply"))
            {
                string temp = Path;
                temp = temp.Replace("Assets/", "/");
                _serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(this);
                int[] list = new int[m_DevicesData.Platforms.Count];

                for (int i = 0; i < m_DevicesData.Platforms.Count; i++)
                {
                    list[i] = m_DevicesData.Platforms[i].Devices.Count;
                }
                Devices tempDevices = JsonUtility.FromJson <Devices>(m_Devices);
                int[]   list2       = new int[tempDevices.Platforms.Count];
                for (int i = 0; i < tempDevices.Platforms.Count; i++)
                {
                    list2[i] = tempDevices.Platforms[i].Devices.Count;
                }

                for (int i = 0; i < list.Length; i++)
                {
                    if (list[i] <= list2[i])
                    {
                        continue;
                    }

                    int NewInt = list[i] - list2[i];
                    for (int j = list2[i]; j < list[i]; j++)
                    {
                        string latPath = Application.dataPath + temp;
                        latPath = latPath.Replace("devices.json", "");
                        DevicesSettingWindow tempWindows = new DevicesSettingWindow();
                        tempWindows.Open(m_DevicesData.Platforms[i].Devices[j], latPath);
                        tempWindows.position = new Rect(j - list2[i] + 0.3f * position.x, position.yMax / 2, 300, 300);
                    }
                }

                File.WriteAllText(Application.dataPath + temp, JsonUtility.ToJson(m_DevicesData, true));
                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();
            }
            #endregion

            #region 添加
            if (GUILayout.Button("Add"))
            {
                string temp = Path;
                temp = temp.Replace("Assets/", "/");
                string latPath = Application.dataPath + temp;
                latPath = latPath.Replace("devices.json", "");
                AddDeviceWindows.Open(latPath);
            }
            #endregion

            #region 重置
            if (GUILayout.Button("Reset"))
            {
                _serializedObject = null;
                isOpen            = false;
            }
            #endregion

            EditorGUILayout.EndVertical();
        }