コード例 #1
0
        private Vector2 m_ScrollPosition4; //滚动视图4

        /// <summary>
        /// 面板GUI
        /// 这里兼容多语言,用的笨方法,以后会改善
        /// </summary>
        void OnGUI()
        {
            //GUI样式
            GUIStyle header = new GUIStyle();

            header.fontSize         = 20;
            header.normal.textColor = Color.white;

            GUIStyle body = new GUIStyle();

            body.fontSize         = 13;
            body.normal.textColor = Color.red;
            GUILayout.BeginVertical();
            EditorStyles.textArea.wordWrap = true;

            if (Language == Language.中文)
            {
                //全部Key区域
                GUILayout.BeginArea(new Rect(25, 10, this.position.width / 3, this.position.height - 10));

                EditorGUILayout.LabelField("Db" + SQL_DB + "中的Keys", header);
                GUILayout.Space(5);
                EditorGUILayout.LabelField("共" + Keys.Count + "Keys", body);
                if (GUILayout.Button("新增"))
                {
                    CurrentValue = "";
                    CurrentKey   = "";
                    SelectedKey  = "";
                    this.Repaint();
                }
                GUILayout.Space(10);

                m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
                foreach (var key in Keys)
                {
                    if (GUILayout.Button(key))
                    {
                        GetValue(key);
                    }
                }
                GUILayout.Space(10);
                GUILayout.EndScrollView();
                GUILayout.EndArea();


                //配置+数据区域
                GUILayout.BeginArea(new Rect(this.position.width / 3 + 50, 10, this.position.width / 3 * 2 - 75, this.position.height - 110));
                EditorGUILayout.HelpBox("Unity GUI Redis\n" +
                                        "作者: 傑", MessageType.Info);
                Language = (Language)EditorGUILayout.EnumPopup("语言(Language)", Language);
                //配置区域
                m_ScrollPosition2     = EditorGUILayout.BeginScrollView(m_ScrollPosition2);
                this.fadeGroup.target = EditorGUILayout.Foldout(this.fadeGroup.target, "基础设置", true);
                if (EditorGUILayout.BeginFadeGroup(this.fadeGroup.faded))
                {
                    EditorGUILayout.HelpBox("注意:\n如果Redis服务器外网没访问权,请使用SSH连接\n如果通过SSH连接,数据库IP为Redis配置文件中绑定的地址(理论上为127.0.0.1)\n如果不通过SSH连接,数据库IP为服务器IP\nRedis数据库端口默认是6379\n数据库如果没密码就留空\n数据库默认为0", MessageType.Warning);
                    SQL_IP       = EditorGUILayout.TextField("数据库IP", SQL_IP);
                    SQL_Port     = (uint)EditorGUILayout.IntField("数据库端口", (int)SQL_Port);
                    SQL_Password = EditorGUILayout.PasswordField("数据库密码", SQL_Password);
                    SQL_DB       = EditorGUILayout.IntField("数据库", (int)SQL_DB);
                    Debug        = EditorGUILayout.Toggle("调试模式", Debug);
                    GUILayout.Space(10);
                    ConnectThroughSSH = EditorGUILayout.BeginToggleGroup("使用SSH连接(建议开启)", ConnectThroughSSH);
                    EditorGUILayout.HelpBox("注意:\nSSH服务器必须具有数据库访问权(即数据库在该服务器内或该服务器IP有权限访问数据库)\nSSH端口默认22\nSSH用户为服务器登入用户名,CentOS的机子一般是root,Ubuntu机子是ubuntu,Windows机子是Administrator\nSSH密码为你登入服务器的密码", MessageType.Warning);
                    SSH_Host     = EditorGUILayout.TextField("SSH服务器IP", SSH_Host);
                    SSH_Port     = EditorGUILayout.IntField("端口", SSH_Port);
                    SSH_User     = EditorGUILayout.TextField("用户", SSH_User);
                    SSH_Password = EditorGUILayout.PasswordField("密码", SSH_Password);
                    EditorGUILayout.EndToggleGroup();
                    GUILayout.Space(10);
                }
                EditorGUILayout.EndFadeGroup();
                //数据处理区域
                GUILayout.Space(5);
                CurrentKey = EditorGUILayout.TextField("Key", CurrentKey);
                EditorGUILayout.LabelField("Value");
                m_ScrollPosition3 = EditorGUILayout.BeginScrollView(m_ScrollPosition3);
                CurrentValue      = EditorGUILayout.TextArea(CurrentValue, GUILayout.MinHeight(150), GUILayout.ExpandHeight(true));
                GUILayout.EndScrollView();
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                if (CurrentKey != "" && CurrentValue != "" && SelectedKey != "")
                {
                    if (GUILayout.Button("保存"))
                    {
                        SetValue();
                    }
                    if (GUILayout.Button("删除"))
                    {
                        DeleteValue();
                    }
                }
                else
                {
                    if (GUILayout.Button("新增"))
                    {
                        SetValue();
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.EndScrollView();
                GUILayout.EndArea();
                //按钮区域
                GUILayout.BeginArea(new Rect(this.position.width / 3 + 25 + ((this.position.width / 3 * 2) - 275) / 2, this.position.height - 90, 250, 80));
                m_ScrollPosition4 = EditorGUILayout.BeginScrollView(m_ScrollPosition4);
                if (GUILayout.Button("刷新Keys"))
                {
                    GetKeys();
                }
                if (GUILayout.Button("测试连接"))
                {
                    TestConnection();
                }
                EditorGUILayout.HelpBox("测试连接会阻塞主线程,建议不要在游戏运行时点击测试,慎用!", MessageType.Error);
                GUILayout.EndScrollView();
                GUILayout.EndArea();
                EditorGUILayout.EndVertical();
            }

            #region 如果不需要英文版可以把下面的删了

            else//英文版本
            {
                //全部Key区域
                GUILayout.BeginArea(new Rect(25, 10, this.position.width / 3, this.position.height - 10));

                EditorGUILayout.LabelField("Keys in Db" + SQL_DB + "", header);
                GUILayout.Space(5);
                EditorGUILayout.LabelField(Keys.Count + " Keys in total", body);
                if (GUILayout.Button("Add new key"))
                {
                    CurrentValue = "";
                    CurrentKey   = "";
                    this.Repaint();
                }
                GUILayout.Space(10);

                m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
                foreach (var key in Keys)
                {
                    if (GUILayout.Button(key))
                    {
                        GetValue(key);
                    }
                }
                GUILayout.Space(10);
                GUILayout.EndScrollView();
                GUILayout.EndArea();


                //配置+数据区域
                GUILayout.BeginArea(new Rect(this.position.width / 3 + 50, 10, this.position.width / 3 * 2 - 75, this.position.height - 110));
                EditorGUILayout.HelpBox("Unity GUI Redis\n" +
                                        "Author: JasonXuDeveloper", MessageType.Info);
                Language = (Language)EditorGUILayout.EnumPopup("语言(Language)", Language);
                //配置区域
                m_ScrollPosition2     = EditorGUILayout.BeginScrollView(m_ScrollPosition2);
                this.fadeGroup.target = EditorGUILayout.Foldout(this.fadeGroup.target, "Basics", true);
                if (EditorGUILayout.BeginFadeGroup(this.fadeGroup.faded))
                {
                    EditorGUILayout.HelpBox("Note:\nPlease use SSH if your Redis service refuses to connect from your ip\nWhen you are using SSH, please change the SQL IP to bind IP in your redis configuration (usually is 127.0.0.1)\nIf you are not using SSH, change the SQL IP to you Server IP\nDefault port for Redis is 6379\nRemain SQL Password empty when there is no password\nDefault database is 9", MessageType.Warning);
                    SQL_IP       = EditorGUILayout.TextField("SQL IP", SQL_IP);
                    SQL_Port     = (uint)EditorGUILayout.IntField("SQL Port", (int)SQL_Port);
                    SQL_Password = EditorGUILayout.PasswordField("SQL Password", SQL_Password);
                    SQL_DB       = EditorGUILayout.IntField("Database", (int)SQL_DB);
                    Debug        = EditorGUILayout.Toggle("Debug mode", Debug);
                    GUILayout.Space(10);
                    ConnectThroughSSH = EditorGUILayout.BeginToggleGroup("Use SSH (Highly recommended)", ConnectThroughSSH);
                    EditorGUILayout.HelpBox("Note:\nSSH must be avaliable to connect to Redis\nDefault port for SSH is 22\nSSH Username is usually root on CentOS Machines, ubuntu on Ubuntu Machines, Administrator on Windows\nSSH Password is the password which you access to your machine", MessageType.Warning);
                    SSH_Host     = EditorGUILayout.TextField("SSH IP", SSH_Host);
                    SSH_Port     = EditorGUILayout.IntField("SSH Port", SSH_Port);
                    SSH_User     = EditorGUILayout.TextField("SSH User", SSH_User);
                    SSH_Password = EditorGUILayout.PasswordField("SSH Password", SSH_Password);
                    EditorGUILayout.EndToggleGroup();
                    GUILayout.Space(10);
                }
                EditorGUILayout.EndFadeGroup();
                //数据处理区域
                GUILayout.Space(5);
                CurrentKey = EditorGUILayout.TextField("Key", CurrentKey);
                EditorGUILayout.LabelField("Value");
                m_ScrollPosition3 = EditorGUILayout.BeginScrollView(m_ScrollPosition3);
                CurrentValue      = EditorGUILayout.TextArea(CurrentValue, GUILayout.MinHeight(150), GUILayout.ExpandHeight(true));
                GUILayout.EndScrollView();
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                if (CurrentKey != "" && CurrentValue != "")
                {
                    if (GUILayout.Button("Save"))
                    {
                        SetValue();
                    }
                    if (GUILayout.Button("Delete"))
                    {
                        DeleteValue();
                    }
                }
                else
                {
                    if (GUILayout.Button("Add New"))
                    {
                        SetValue();
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.EndScrollView();
                GUILayout.EndArea();
                //按钮区域
                GUILayout.BeginArea(new Rect(this.position.width / 3 + 25 + ((this.position.width / 3 * 2) - 275) / 2, this.position.height - 90, 250, 80));
                m_ScrollPosition4 = EditorGUILayout.BeginScrollView(m_ScrollPosition4);
                if (GUILayout.Button("Refresh Keys"))
                {
                    GetKeys();
                }
                if (GUILayout.Button("Test Connection"))
                {
                    TestConnection();
                }
                EditorGUILayout.HelpBox("Test connection will be running on main thread,\nThus it is not recommended to try it while the game is playing,\nPlease be aware before you use this feature", MessageType.Error);
                GUILayout.EndScrollView();
                GUILayout.EndArea();
                EditorGUILayout.EndVertical();
            }
            #endregion
            //删到这里就够了
        }
コード例 #2
0
ファイル: Tools_Module.cs プロジェクト: PgGames/Attribution
        private void CreateModuleUI()
        {
            if (string.IsNullOrEmpty(m_ModuleInfo.ModulePath))
            {
                m_ModuleInfo.Init();
            }
            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
            GUILayout.BeginVertical();
            EditorGUILayout.Space();

            //文件信息
            using (new EditorGUI.DisabledScope())
            {
                m_ModuleInfo.ModulePath = EditorGUILayout.TextField("Folder Path", m_ModuleInfo.ModulePath);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("OpenFile", GUILayout.MaxWidth(Tools_Public.Tools_MinButtonWidth)))
                {
                    var newPath = EditorUtility.OpenFolderPanel("OpenFile", Application.dataPath, "");
                    if (!string.IsNullOrEmpty(newPath))
                    {
                        newPath = newPath.Replace("\\", "/");
                        var temppath = Application.dataPath.Replace("\\", "/");
                        if (newPath.Contains(temppath))
                        {
                            m_ModuleInfo.ModulePath = newPath.Replace(temppath, "");
                            m_ModuleInfo.ModulePath = m_ModuleInfo.ModulePath.TrimStart('/');
                        }
                    }
                }
                if (GUILayout.Button("UpDate", GUILayout.MaxWidth(Tools_Public.Tools_MinButtonWidth)))
                {
                    m_ModuleInfo.Init();
                }
                GUILayout.EndHorizontal();
            }
            //模块信息
            using (new EditorGUI.DisabledScope())
            {
                EditorGUILayout.Space();
                m_ModuleInfo.ModuleName = EditorGUILayout.TextField("Module Name", m_ModuleInfo.ModuleName);
                if (Tools_Public.RightButton("Switch Module", GUILayout.Width(Tools_Public.Tools_ButtonWidth)))
                {
                    SwitchModule();
                }
                m_ModuleInfo.ModuleTips    = EditorGUILayout.TextField("Module Tips", m_ModuleInfo.ModuleTips);
                m_ModuleInfo.IsVideoPlayer = EditorGUILayout.Toggle("VideoPlayer", m_ModuleInfo.IsVideoPlayer);
                m_ModuleInfo.IsAnimations  = EditorGUILayout.Toggle("Animations", m_ModuleInfo.IsAnimations);
                m_ModuleInfo.IsAudioClip   = EditorGUILayout.Toggle("AudioClip", m_ModuleInfo.IsAudioClip);
                m_ModuleInfo.IsTexture     = EditorGUILayout.Toggle("Texture", m_ModuleInfo.IsTexture);
                m_ModuleInfo.IsShader      = EditorGUILayout.Toggle("Shader", m_ModuleInfo.IsShader);
                m_ModuleInfo.IsUI          = EditorGUILayout.Toggle("UI", m_ModuleInfo.IsUI);
                m_ModuleInfo.IsTxt         = EditorGUILayout.Toggle("Txt", m_ModuleInfo.IsTxt);
            }

            //创建模块
            using (new EditorGUI.DisabledScope())
            {
                if (Tools_Public.CenterButton("Create Module", GUILayout.MaxWidth(Tools_Public.Tools_MaxButtonWidth)))
                {
                    string temp_path = Application.dataPath + "/" + m_ModuleInfo.ModulePath;
                    CreateFolder(temp_path, m_ModuleInfo.ModuleName, m_ModuleInfo.ModuleTips);
                }
            }
            GUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
コード例 #3
0
 private void OnGUI()
 {
     EditorGUILayout.BeginVertical();
     scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
     GUILayout.Label("Tools to Quickly Update Rigidbody and Configurable joint properties.");
     PlantBase = (GameObject)EditorGUILayout.ObjectField("Base GameObject:", PlantBase, typeof(GameObject), true);
     if (GUILayout.Button("Update Configurable Joints and Rigidbodies"))
     {
         UpdateConfigurableJointsAndRigidbodies();
     }
     if (GUILayout.Button("Update Configurable Joints"))
     {
         UpdateConfigurableJoints();
     }
     if (GUILayout.Button("Update Rigidbodies"))
     {
         UpdateRigidbodies();
     }
     GUILayout.Label("-------------", EditorStyles.boldLabel);
     rigidbodyPropertyGroup = EditorGUILayout.BeginToggleGroup("Rigidbody Properties", rigidbodyPropertyGroup);
     if (rigidbodyPropertyGroup)
     {
         GUILayout.Label("See Unity manual online for description of properties.");
         RigidbodyMass              = EditorGUILayout.FloatField("Mass:", RigidbodyMass);
         RigidbodyDrag              = EditorGUILayout.FloatField("Drag:", RigidbodyDrag);
         RigidbodyAngDrag           = EditorGUILayout.FloatField("Angular Drag:", RigidbodyAngDrag);
         RigidbodyUseGravity        = EditorGUILayout.Toggle("Use Gravity:", RigidbodyUseGravity);
         RigidbodyIsKinematic       = EditorGUILayout.Toggle("Is Kinematic:", RigidbodyIsKinematic);
         RigidbodyInterpolationType =
             (RigidbodyInterpolation)
             EditorGUILayout.EnumPopup("Interpolation Type:", RigidbodyInterpolationType);
         RigidbodyCollisionType =
             (CollisionDetectionMode)
             EditorGUILayout.EnumPopup("Collision Detection Type:", RigidbodyCollisionType);
     }
     EditorGUILayout.EndToggleGroup();
     configurableJointPropertyGroup = EditorGUILayout.BeginToggleGroup("Configurable Joint Properties",
                                                                       configurableJointPropertyGroup);
     if (configurableJointPropertyGroup)
     {
         GUILayout.Label("See Unity manual online for description of properties.");
         GUILayout.Label("Angular X Limit Spring:");
         AngXLimitSping  = EditorGUILayout.FloatField("    Spring:", AngXLimitSping);
         AngXLimitDamper = EditorGUILayout.FloatField("    Damper:", AngXLimitDamper);
         GUILayout.Label("Low Angular X Limit:");
         LowAngXLimitLim         = EditorGUILayout.FloatField("    Limit:", LowAngXLimitLim);
         LowAngXLimitBounce      = EditorGUILayout.FloatField("    Bounciness:", LowAngXLimitBounce);
         LowAngXLimitContactDist = EditorGUILayout.FloatField("    Contact Distance:", LowAngXLimitContactDist);
         GUILayout.Label("High Angular X Limit:");
         HighAngXLimitLim         = EditorGUILayout.FloatField("    Limit:", HighAngXLimitLim);
         HighAngXLimitBounce      = EditorGUILayout.FloatField("    Bounciness:", HighAngXLimitBounce);
         HighAngXLimitContactDist = EditorGUILayout.FloatField("    Contact Distance:", HighAngXLimitContactDist);
         GUILayout.Label("Angular YZ Limit Spring:");
         AngYZLimitSping  = EditorGUILayout.FloatField("    Spring:", AngYZLimitSping);
         AngYZLimitDamper = EditorGUILayout.FloatField("    Damper:", AngYZLimitDamper);
         GUILayout.Label("Angular Y Limit:");
         AngYLimitLim         = EditorGUILayout.FloatField("    Limit:", AngYLimitLim);
         AngYLimitBounce      = EditorGUILayout.FloatField("    Bounciness:", AngYLimitBounce);
         AngYLimitContactDist = EditorGUILayout.FloatField("    Contact Distance:", AngYLimitContactDist);
         GUILayout.Label("Angular Z Limit:");
         AngZLimitLim         = EditorGUILayout.FloatField("    Limit:", AngZLimitLim);
         AngZLimitBounce      = EditorGUILayout.FloatField("    Bounciness:", AngZLimitBounce);
         AngZLimitContactDist = EditorGUILayout.FloatField("    Contact Distance:", AngZLimitContactDist);
         if (rotationDriveMode == RotationDriveMode.Slerp)
         {
             GUILayout.Label("Slerp Drive:");
             SlerpDrivePosSpring = EditorGUILayout.FloatField("    Position Spring:", SlerpDrivePosSpring);
             SlerpDrivePosDamper = EditorGUILayout.FloatField("    Position Damper:", SlerpDrivePosDamper);
             SlerpDriveMaxForce  = EditorGUILayout.FloatField("    Maximum Force:", SlerpDriveMaxForce);
         }
         ProjectionDistance     = EditorGUILayout.FloatField("Projection Distance:", ProjectionDistance);
         ProjectionAngle        = EditorGUILayout.FloatField("Projection Angle:", ProjectionAngle);
         ConfiguredInWorldSpace = EditorGUILayout.Toggle("Configured In World Space", ConfiguredInWorldSpace);
         SwapBodies             = EditorGUILayout.Toggle("Swap Bodies:", SwapBodies);
         BreakForce             = EditorGUILayout.FloatField("Break Force:", BreakForce);
         BreakTorque            = EditorGUILayout.FloatField("Break Torque:", BreakTorque);
         EnableCollision        = EditorGUILayout.Toggle("Enable Collision:", EnableCollision);
         EnablePreProcessing    = EditorGUILayout.Toggle("EnablePreProcessiong:", EnablePreProcessing);
     }
     EditorGUILayout.EndToggleGroup();
     GUILayout.Label("Quick Start:");
     GUILayout.Label("1. Adjust properties in foldouts above");
     GUILayout.Label("2a. Set Base GameObject field above to single plant");
     GUILayout.Label("OR");
     GUILayout.Label("2b. Select multiple Plant GameObjects using Scene Hierarchy");
     GUILayout.Label("3. Click Update Buttons");
     EditorGUILayout.EndScrollView();
     EditorGUILayout.EndVertical();
 }
コード例 #4
0
    public override void OnInspectorGUI()
    {
        tk2dTextMesh textMesh = (tk2dTextMesh)target;

        // maybe cache this if its too slow later
        if (allBmFontImporters == null)
        {
            allBmFontImporters = tk2dEditorUtility.GetOrCreateIndex().GetFonts();
        }

        if (allBmFontImporters != null)
        {
            if (textMesh.font == null)
            {
                textMesh.font = allBmFontImporters[0].data;
            }

            int      currId    = -1;
            string[] fontNames = new string[allBmFontImporters.Length];
            for (int i = 0; i < allBmFontImporters.Length; ++i)
            {
                fontNames[i] = allBmFontImporters[i].name;
                if (allBmFontImporters[i].data == textMesh.font)
                {
                    currId = i;
                }
            }

            int newId = EditorGUILayout.Popup("Font", currId, fontNames);
            if (newId != currId)
            {
                textMesh.font = allBmFontImporters[newId].data;
                textMesh.renderer.material = allBmFontImporters[newId].material;
            }

            EditorGUILayout.BeginHorizontal();
            textMesh.maxChars = EditorGUILayout.IntField("Max Chars", textMesh.maxChars);
            if (textMesh.maxChars < 1)
            {
                textMesh.maxChars = 1;
            }
            if (textMesh.maxChars > 16000)
            {
                textMesh.maxChars = 16000;
            }
            if (GUILayout.Button("Fit", GUILayout.MaxWidth(32.0f)))
            {
                textMesh.maxChars = textMesh.NumTotalCharacters();
                GUI.changed       = true;
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Text");
            textMesh.text = EditorGUILayout.TextArea(textMesh.text, GUILayout.Height(64));
            GUILayout.EndHorizontal();

            textMesh.anchor      = (TextAnchor)EditorGUILayout.EnumPopup("Anchor", textMesh.anchor);
            textMesh.kerning     = EditorGUILayout.Toggle("Kerning", textMesh.kerning);
            textMesh.spacing     = EditorGUILayout.FloatField("Spacing", textMesh.spacing);
            textMesh.lineSpacing = EditorGUILayout.FloatField("Line Spacing", textMesh.lineSpacing);
            textMesh.scale       = EditorGUILayout.Vector3Field("Scale", textMesh.scale);

            if (textMesh.font.textureGradients && textMesh.font.gradientCount > 0)
            {
                //textMesh.textureGradient = EditorGUILayout.IntSlider("Gradient", textMesh.textureGradient, 0, textMesh.font.gradientCount - 1);

                GUILayout.BeginHorizontal();

                EditorGUILayout.PrefixLabel("TextureGradient");

                // Draw gradient scroller
                bool drawGradientScroller = true;
                if (drawGradientScroller)
                {
                    textMesh.textureGradient = textMesh.textureGradient % textMesh.font.gradientCount;

                    gradientScroll = EditorGUILayout.BeginScrollView(gradientScroll, GUILayout.ExpandHeight(false));
                    Rect r = GUILayoutUtility.GetRect(textMesh.font.gradientTexture.width, textMesh.font.gradientTexture.height, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));
                    GUI.DrawTexture(r, textMesh.font.gradientTexture);

                    Rect hr = r;
                    hr.width /= textMesh.font.gradientCount;
                    hr.x     += hr.width * textMesh.textureGradient;
                    float     ox        = hr.width / 8;
                    float     oy        = hr.height / 8;
                    Vector3[] rectVerts = { new Vector3(hr.x + 0.5f + ox, hr.y + oy, 0), new Vector3(hr.x + hr.width - ox, hr.y + oy, 0), new Vector3(hr.x + hr.width - ox, hr.y + hr.height - 0.5f - oy, 0), new Vector3(hr.x + ox, hr.y + hr.height - 0.5f - oy, 0) };
                    Handles.DrawSolidRectangleWithOutline(rectVerts, new Color(0, 0, 0, 0.2f), new Color(0, 0, 0, 1));

                    if (GUIUtility.hotControl == 0 && Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition))
                    {
                        textMesh.textureGradient = (int)(Event.current.mousePosition.x / (textMesh.font.gradientTexture.width / textMesh.font.gradientCount));
                        GUI.changed = true;
                    }

                    EditorGUILayout.EndScrollView();
                }


                GUILayout.EndHorizontal();

                textMesh.inlineStyling = EditorGUILayout.Toggle("Inline Styling", textMesh.inlineStyling);
                if (textMesh.inlineStyling)
                {
                    Color bg = GUI.backgroundColor;
                    GUI.backgroundColor = new Color32(154, 176, 203, 255);
                    GUILayout.TextArea("Inline style commands\n" +
                                       "^0-9 - select gradient\n" +
                                       "^^ - print ^");
                    GUI.backgroundColor = bg;
                }
            }

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("HFlip"))
            {
                Vector3 s = textMesh.scale;
                s.x           *= -1.0f;
                textMesh.scale = s;
                GUI.changed    = true;
            }
            if (GUILayout.Button("VFlip"))
            {
                Vector3 s = textMesh.scale;
                s.y           *= -1.0f;
                textMesh.scale = s;
                GUI.changed    = true;
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Bake Scale"))
            {
                tk2dScaleUtility.Bake(textMesh.transform);
                GUI.changed = true;
            }

            GUIContent pixelPerfectButton = new GUIContent("1:1", "Make Pixel Perfect");
            if (GUILayout.Button(pixelPerfectButton))
            {
                if (tk2dPixelPerfectHelper.inst)
                {
                    tk2dPixelPerfectHelper.inst.Setup();
                }
                textMesh.MakePixelPerfect();
                GUI.changed = true;
            }
            textMesh.pixelPerfect = GUILayout.Toggle(textMesh.pixelPerfect, "Always", GUILayout.Width(60.0f));

            EditorGUILayout.EndHorizontal();

            textMesh.useGradient = EditorGUILayout.Toggle("Use Gradient", textMesh.useGradient);
            if (textMesh.useGradient)
            {
                textMesh.color  = EditorGUILayout.ColorField("Top Color", textMesh.color);
                textMesh.color2 = EditorGUILayout.ColorField("Bottom Color", textMesh.color2);
            }
            else
            {
                textMesh.color = EditorGUILayout.ColorField("Color", textMesh.color);
            }

            if (GUI.changed)
            {
                textMesh.Commit();
                EditorUtility.SetDirty(textMesh);
            }
        }
    }
コード例 #5
0
    void OnGUI()
    {
        var so = new SerializedObject(this);

        var list = so.FindProperty("matInfos");

        if (GUILayout.Button("Add New Mat Info Group"))
        {
            matInfos.Add(new MatInfo());
        }


        if (GUILayout.Button("Remove Last Mat Info Group"))
        {
            matInfos.RemoveAt(matInfos.Count - 1);
        }


        if (matInfos == null)
        {
            return;
        }
        EditorGUILayout.BeginVertical();
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        for (int i = 0; i < matInfos.Count; i++)
        {
            EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
            // var group = lis
            // group.material = EditorGUILayout.ObjectField(group.material, typeof(Material), false) as Material;
            // group.parentNamePattern = EditorGUILayout.TextField("Parent Object Name", group.parentNamePattern);
            // group.namePattern = EditorGUILayout.TextField("Match Pattern", group.namePattern);
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();


        if (GUILayout.Button("Assign Away"))
        {
            foreach (var i in matInfos)
            {
                var containerRegex = new Regex(i.parentNamePattern);
                var objectRegex    = new Regex(i.namePattern);

                var containers = GameObject.FindObjectsOfType <Transform>();
                foreach (var container in containers)
                {
                    if (containerRegex.IsMatch(container.name))
                    {
                        var allRends = container.GetComponentsInChildren <Renderer>().ToList();
                        allRends.ForEach(rend =>
                        {
                            if (objectRegex.IsMatch(rend.name))
                            {
                                rend.sharedMaterial = i.material;
                            }
                        });
                    }
                }
            }
        }


        so.ApplyModifiedProperties();



        // GUILayout.Label("Base Settings", EditorStyles.boldLabel);
        // myString = EditorGUILayout.TextField("Text Field", myString);

        // groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
        // myBool = EditorGUILayout.Toggle("Toggle", myBool);
        // myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3);
        // EditorGUILayout.EndToggleGroup();
    }
コード例 #6
0
ファイル: AssetBundleWindow.cs プロジェクト: hafewa/MMORPG-4
    /// <summary>
    /// 绘制窗口
    /// </summary>
    void OnGUI()
    {
        if (m_List == null)
        {
            return;
        }

        #region  钮行
        GUILayout.BeginHorizontal("box");

        selectTagIndex = EditorGUILayout.Popup(tagIndex, arrTag, GUILayout.Width(100));
        if (selectTagIndex != tagIndex)
        {
            tagIndex = selectTagIndex;
            EditorApplication.delayCall = OnSelectTagCallBack;
        }


        selectBuildTargetIndex = EditorGUILayout.Popup(buildTargetIndex, arrBuildTarget, GUILayout.Width(100));
        if (selectBuildTargetIndex != buildTargetIndex)
        {
            buildTargetIndex            = selectBuildTargetIndex;
            EditorApplication.delayCall = OnSelectTargetCallBack;
        }

        if (GUILayout.Button("保存设置", GUILayout.Width(200)))
        {
            EditorApplication.delayCall = OnSaveAssetBundleCallBack;;
        }

        if (GUILayout.Button("清空AssetBundle包", GUILayout.Width(200)))
        {
            EditorApplication.delayCall = OnClearAssetBundleCallBack;
        }

        if (GUILayout.Button("打AssetBundle包", GUILayout.Width(200)))
        {
            EditorApplication.delayCall = OnAssetBundleCallBack;
        }

        if (GUILayout.Button("拷贝数据表", GUILayout.Width(200)))
        {
            EditorApplication.delayCall = OnCopyDataTableCallBack;
        }

        if (GUILayout.Button("生成版本文件", GUILayout.Width(200)))
        {
            EditorApplication.delayCall = OnCreateVersionFileCallBack;
        }

        EditorGUILayout.Space();

        GUILayout.EndHorizontal();
        #endregion

        GUILayout.BeginHorizontal("box");
        GUILayout.Label("包名");
        GUILayout.Label("标记", GUILayout.Width(100));
        GUILayout.Label("文件夹", GUILayout.Width(200));
        GUILayout.Label("初始资源", GUILayout.Width(200));
        GUILayout.EndHorizontal();

        GUILayout.BeginVertical();

        pos = EditorGUILayout.BeginScrollView(pos);

        for (int i = 0; i < m_List.Count; i++)
        {
            AssetBundleEntity entity = m_List[i];

            GUILayout.BeginHorizontal("box");

            m_Dic[entity.Key] = GUILayout.Toggle(m_Dic[entity.Key], "", GUILayout.Width(20));
            GUILayout.Label(entity.Name);
            GUILayout.Label(entity.Tag, GUILayout.Width(100));
            GUILayout.Label(entity.IsFolder.ToString(), GUILayout.Width(200));
            GUILayout.Label(entity.IsFirstData.ToString(), GUILayout.Width(200));
            GUILayout.EndHorizontal();

            foreach (string path in entity.PathList)
            {
                GUILayout.BeginHorizontal("box");
                GUILayout.Space(40);
                GUILayout.Label(path);
                GUILayout.EndHorizontal();
            }
        }

        EditorGUILayout.EndScrollView();

        GUILayout.EndVertical();
    }
コード例 #7
0
    //bool confirmButton;
    private void OnGUI()
    {
        if (serializedObject == null)
        {
            return;
        }
        currentProperty = serializedObject.FindProperty("itemsList");

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.BeginVertical("box", GUILayout.MaxWidth(150), GUILayout.ExpandHeight(true));

        sideBar = EditorGUILayout.BeginScrollView(sideBar);
        DrawSidebar(currentProperty);
        EditorGUILayout.EndScrollView();

        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box", GUILayout.ExpandHeight(true));
        if (selectedProperty != null)
        {
            content = EditorGUILayout.BeginScrollView(content);
            if (!showItemAssets)
            {
                EditorGUILayout.PropertyField(selectedProperty, true);
            }
            else
            {
                serializedObject.FindProperty("id").intValue       = EditorGUILayout.IntField(new GUIContent("Item Asset id"), serializedObject.FindProperty("id").intValue);
                serializedObject.FindProperty("strId").stringValue = EditorGUILayout.TextField(new GUIContent("Item Asset key"), serializedObject.FindProperty("strId").stringValue);
            }

            /*if (GUILayout.Button("Remove Item", GUILayout.Width(150), GUILayout.Height(20)))
             * {
             *  confirmButton = !confirmButton;
             * }
             * if(confirmButton)
             * {
             *  if (GUILayout.Button("Confirm", GUILayout.Width(150), GUILayout.Height(20)))
             *  {
             *      for(int i = 0;i < currentProperty.arraySize;i++)
             *      {
             *          if(currentProperty.GetArrayElementAtIndex(i) == selectedProperty)
             *          {
             *              AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(selectedProperty.objectReferenceInstanceIDValue));
             *              List<SerializedProperty> props = new List<SerializedProperty>();
             *
             *              currentProperty.DeleteArrayElementAtIndex(i);
             *
             *              for(int j = 0;j < currentProperty.arraySize;j++)
             *              {
             *                  if(currentProperty.GetArrayElementAtIndex(j) != null)
             *                  {
             *                      props.Add(currentProperty.GetArrayElementAtIndex(j));
             *                  }
             *              }
             *
             *          }
             *      }
             *  }
             *  if (GUILayout.Button("Cancel", GUILayout.Width(150), GUILayout.Height(20)))
             *  {
             *      confirmButton = false;
             *  }
             * }
             * //DrawProperties(selectedProperty, true);*/
            EditorGUILayout.EndScrollView();
        }
        else
        {
            EditorGUILayout.LabelField("Select an item from the list");
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        serializedObject.ApplyModifiedProperties();
    }
コード例 #8
0
 public override void DoGUI()
 {
     SkillEditorStyles.Init();
     SkillEditorGUILayout.ToolWindowLargeTitle(this, Strings.get_BugReportWindow_Title());
     SkillEditorGUILayout.LabelWidth(200f);
     this.controlsScrollPosition = EditorGUILayout.BeginScrollView(this.controlsScrollPosition, new GUILayoutOption[0]);
     GUILayout.Label(Strings.get_BugReportWindow_Bug_Title_Label(), EditorStyles.get_boldLabel(), new GUILayoutOption[0]);
     this.description = EditorGUILayout.TextField(this.description, new GUILayoutOption[0]);
     GUILayout.Label(Strings.get_BugReportWindow_Bug_Description_Label(), EditorStyles.get_boldLabel(), new GUILayoutOption[0]);
     this.extra = EditorGUILayout.TextArea(this.extra, SkillEditorStyles.TextAreaWithWordWrap, new GUILayoutOption[]
     {
         GUILayout.ExpandHeight(true)
     });
     this.area           = (BugReportWindow.ScoutArea)EditorGUILayout.EnumPopup(Strings.get_BugReportWindow_Where_does_it_happen(), this.area, new GUILayoutOption[0]);
     this.frequencyIndex = EditorGUILayout.Popup(Strings.get_BugReportWindow_How_often_does_it_happen(), this.frequencyIndex, BugReportWindow.frequencyChoices, new GUILayoutOption[0]);
     this.email          = EditorGUILayout.TextField(new GUIContent(Strings.get_BugReportWindow_Your_E_mail(), Strings.get_BugReportWindow_Your_E_mail_Tooltip()), this.email, new GUILayoutOption[0]);
     EditorGUILayout.EndScrollView();
     SkillEditorGUILayout.Divider(new GUILayoutOption[0]);
     GUILayout.BeginHorizontal(new GUILayoutOption[0]);
     GUILayout.Label("PlayMaker: " + VersionInfo.AssemblyVersion, new GUILayoutOption[0]);
     GUILayout.Label("Unity: " + Application.get_unityVersion(), new GUILayoutOption[0]);
     GUILayout.Label("Build Target: " + EditorUserBuildSettings.get_activeBuildTarget(), new GUILayoutOption[0]);
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
     SkillEditorGUILayout.Divider(new GUILayoutOption[0]);
     GUILayout.BeginHorizontal(new GUILayoutOption[0]);
     if (GUILayout.Button(Strings.get_BugReportWindow_Submit_Button(), new GUILayoutOption[0]))
     {
         if (!this.isValid)
         {
             EditorUtility.DisplayDialog(Strings.get_BugReportWindow_Title(), this.errorString, Strings.get_OK());
         }
         else
         {
             this.SubmitBugReportByMail();
         }
         GUIUtility.ExitGUI();
         return;
     }
     if (GUILayout.Button(new GUIContent(Strings.get_Command_Copy(), Strings.get_BugReportWindow_Copy_Tooltip()), new GUILayoutOption[]
     {
         GUILayout.MaxWidth(100f)
     }))
     {
         this.CopyReportToClipboard();
     }
     if (GUILayout.Button(new GUIContent(Strings.get_Command_Reset()), new GUILayoutOption[]
     {
         GUILayout.MaxWidth(100f)
     }))
     {
         GUIUtility.set_keyboardControl(0);
         this.Reset();
     }
     GUILayout.EndHorizontal();
     GUILayout.Space(10f);
     if (GUI.get_changed())
     {
         this.UpdateGUI();
         GUIUtility.ExitGUI();
     }
 }
コード例 #9
0
        // -----------------------
        void OnGUI()
        {
            const float BUTTON_HEIGHT          = 30;
            const float TOOLBAR_HEIGHT         = 34;
            const float PROP_BOX_BUTTON_HEIGHT = 20;
            const float MAX_PROP_BOX_HEIGHT    = 300;
            const float ENTRY_LIST_REL_HEIGHT  = 0.55f;


            float entryListHeight = (this.position.height - TOOLBAR_HEIGHT) - PROP_BOX_BUTTON_HEIGHT - 100;
            float propBoxHeight   = Mathf.Min((MAX_PROP_BOX_HEIGHT), (entryListHeight * (1.0f - ENTRY_LIST_REL_HEIGHT)));


            GUILayout.Box(GUIContent.none, CFEditorStyles.Inst.headerAssistant, GUILayout.ExpandWidth(true));


            EditorGUILayout.BeginHorizontal(CFEditorStyles.Inst.toolbarBG);

            this.recordingOn = CFGUI.PushButton(
                new GUIContent("Capture in progress!", CFEditorStyles.Inst.greenDotTex, "Editor must be in Play mode to catch Input calls!"),
                new GUIContent("Stopped. Press to begin capture", CFEditorStyles.Inst.pauseTex, "Editor must be in Play mode to catch Input calls!"),
                this.recordingOn, CFEditorStyles.Inst.buttonStyle, GUILayout.Height(BUTTON_HEIGHT), GUILayout.ExpandWidth(true));

            GUI.backgroundColor = (Color.white);

            if (GUILayout.Button("Clear", GUILayout.Height(BUTTON_HEIGHT), GUILayout.Width(70)))
            {
                this.ClearEntries();
            }

            EditorGUILayout.EndHorizontal();


            if (this.selectedRig == null)
            {
                EditorGUILayout.HelpBox("No rig selected!! Select one to be able to easily create controls or bind commands!", MessageType.Warning);
            }
            else
            {
                EditorGUILayout.HelpBox("Rig: " + this.selectedRig.name, MessageType.None);
            }

            if (!CFUtils.editorStopped && (this.logEntries.Count > 0))
            {
                EditorGUILayout.HelpBox("Remember to stop Editor before binding or creating controls!", MessageType.Warning);
            }


            this.scrollPos = EditorGUILayout.BeginScrollView(this.scrollPos, CFEditorStyles.Inst.transpSunkenBG, GUILayout.ExpandHeight(true));     //GUILayout.Height(entryListHeight));

            if (this.logEntries.Count == 0)
            {
                GUILayout.Box("Nothing captured yet!" + (CFUtils.editorStopped ? "\nTo capture anything hit the PLAY button!" : ""),
                              CFEditorStyles.Inst.centeredTextTranspBG);
            }
            else
            {
                for (int i = this.logEntries.Count - 1; i >= 0; --i)
                {
                    //GUILayout.Label("[" + i + "] : " + this.logEntries[i].ToString());
                    this.logEntries[i].DrawListElemGUI(this);
                }
            }

            EditorGUILayout.EndScrollView();

            if (this.selectedEntry != null)
            {
                this.propBoxOn = CFGUI.PushButton(
                    new GUIContent("Hide Properties", CFEditorStyles.Inst.texMoveDown),
                    new GUIContent("Show Properties", CFEditorStyles.Inst.texMoveUp),
                    this.propBoxOn, CFEditorStyles.Inst.buttonStyle);

                if (this.propBoxOn)
                {
                    this.propBoxScroll = EditorGUILayout.BeginScrollView(this.propBoxScroll, CFEditorStyles.Inst.transpSunkenBG, GUILayout.Height(propBoxHeight));

                    this.selectedEntry.DrawPropertiesGUI();

                    EditorGUILayout.EndScrollView();
                }
            }
        }
コード例 #10
0
        public void OnGUI(Rect pos)
        {
            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
            bool newState      = false;
            var  centeredStyle = GUI.skin.GetStyle("Label");

            centeredStyle.alignment = TextAnchor.UpperCenter;
            GUILayout.Label(new GUIContent("Example build setup"), centeredStyle);
            //basic options
            EditorGUILayout.Space();
            GUILayout.BeginVertical();

            // build target
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildTarget)) {
                ValidBuildTarget tgt = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_UserData.m_BuildTarget);
                if (tgt != m_UserData.m_BuildTarget)
                {
                    m_UserData.m_BuildTarget = tgt;
                    if (m_UserData.m_UseDefaultPath)
                    {
                        m_UserData.m_OutputPath  = "AssetBundles/";
                        m_UserData.m_OutputPath += m_UserData.m_BuildTarget.ToString();
                        //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath);
                    }
                }
            }


            ////output path
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOutputDirectory)) {
                EditorGUILayout.Space();
                GUILayout.BeginHorizontal();
                var newPath = EditorGUILayout.TextField("Output Path", m_UserData.m_OutputPath);
                if ((newPath != m_UserData.m_OutputPath) &&
                    (newPath != string.Empty))
                {
                    m_UserData.m_UseDefaultPath = false;
                    m_UserData.m_OutputPath     = newPath;
                    //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath);
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f)))
                {
                    BrowseForFolder();
                }
                if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f)))
                {
                    ResetPathToDefault();
                }
                //if (string.IsNullOrEmpty(m_OutputPath))
                //    m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath");
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();

                newState = GUILayout.Toggle(
                    m_ForceRebuild.state,
                    m_ForceRebuild.content);
                if (newState != m_ForceRebuild.state)
                {
                    if (newState)
                    {
                        m_UserData.m_OnToggles.Add(m_ForceRebuild.content.text);
                    }
                    else
                    {
                        m_UserData.m_OnToggles.Remove(m_ForceRebuild.content.text);
                    }
                    m_ForceRebuild.state = newState;
                }
                newState = GUILayout.Toggle(
                    m_CopyToStreaming.state,
                    m_CopyToStreaming.content);
                if (newState != m_CopyToStreaming.state)
                {
                    if (newState)
                    {
                        m_UserData.m_OnToggles.Add(m_CopyToStreaming.content.text);
                    }
                    else
                    {
                        m_UserData.m_OnToggles.Remove(m_CopyToStreaming.content.text);
                    }
                    m_CopyToStreaming.state = newState;
                }
            }

            // advanced options
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOptions)) {
                EditorGUILayout.Space();
                m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings");
                if (m_AdvancedSettings)
                {
                    var indent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel = 1;
                    CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup(
                        m_CompressionContent,
                        (int)m_UserData.m_Compression,
                        m_CompressionOptions,
                        m_CompressionValues);

                    if (cmp != m_UserData.m_Compression)
                    {
                        m_UserData.m_Compression = cmp;
                    }
                    foreach (var tog in m_ToggleData)
                    {
                        newState = EditorGUILayout.ToggleLeft(
                            tog.content,
                            tog.state);
                        if (newState != tog.state)
                        {
                            if (newState)
                            {
                                m_UserData.m_OnToggles.Add(tog.content.text);
                            }
                            else
                            {
                                m_UserData.m_OnToggles.Remove(tog.content.text);
                            }
                            tog.state = newState;
                        }
                    }
                    EditorGUILayout.Space();
                    EditorGUI.indentLevel = indent;
                }
            }

            // build.
            EditorGUILayout.Space();
            if (GUILayout.Button("Build"))
            {
                CreateConfig.MenuCreateConfigAsset();
                EditorApplication.delayCall += ExecuteBuild;
            }
            GUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
コード例 #11
0
    public override void OnInspectorGUI()
    {
        //check for points changed
        if (GUI.changed == true)
        {
            sc.predefinedPoints = predefinedmPoints;
        }
        else
        {
            predefinedmPoints = sc.predefinedPoints;
        }


        EditorGUILayout.Space();

        //select the type of cover system
        coverSystemToUse = (CoverSystem)EditorGUILayout.EnumPopup("Which cover system to use: ", coverSystemToUse);

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();


        //set the varaibles correctly
        if (Selection.gameObjects.Length == 0)
        {
            return;
        }


        if (GUILayout.Button("Create New Cover Position"))
        {
            predefinedmPoints.Add(Vector3.zero);
        }


        //make the scroll group
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(100f));

        //make each point visible and manipulatable
        for (int x = 0; x < predefinedmPoints.Count; x++)
        {
            //in the tab
            EditorGUILayout.BeginHorizontal();
            {
                predefinedmPoints[x] = EditorGUILayout.Vector3Field(x.ToString(), predefinedmPoints[x]);

                if (GUILayout.Button("X"))
                {
                    predefinedmPoints.Remove(predefinedmPoints[x]);
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        //end scroll pos
        EditorGUILayout.EndScrollView();


        //save to file
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Save to File"))
        {
            //write to file
            string saveFile = "";
            for (int x = 0; x < predefinedmPoints.Count; x++)
            {
                //add seperator
                saveFile += "/";

                //add the individual components
                saveFile += predefinedmPoints[x].x.ToString();
                saveFile += "~";
                saveFile += predefinedmPoints[x].y.ToString();
                saveFile += "~";
                saveFile += predefinedmPoints[x].z.ToString();
            }

            System.IO.File.WriteAllText(fileSaveLoc, saveFile);
        }

        fileSaveLoc = EditorGUILayout.TextField(fileSaveLoc);

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        //load from file
        if (GUILayout.Button("Load from File"))
        {
            //open the file first
            string rawFile = System.IO.File.ReadAllText(fileOpenLoc);

            //parse first all the individual vectors
            string[] vectors = rawFile.Split("/".ToCharArray()[0]);

            //now correctly fill up the array
            predefinedmPoints.Clear();

            //loop through al; start at 1 to skip the first which is a blank
            for (int x = 1; x < vectors.Length; x++)
            {
                //split up the vectors
                string[] component = vectors[x].Split("~".ToCharArray()[0]);

                //put in the component
                Vector3 newCoverPos = Vector3.zero;

                newCoverPos.x = float.Parse(component[0]);
                newCoverPos.y = float.Parse(component[1]);
                newCoverPos.z = float.Parse(component[2]);

                //add it to the main array
                predefinedmPoints.Add(newCoverPos);
            }
        }
        fileOpenLoc = EditorGUILayout.TextField(fileOpenLoc);

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();


        //check for coversystem change
        if (GUI.changed == true)
        {
            sc.coverSystemToUse = coverSystemToUse;
        }
        else
        {
            coverSystemToUse = sc.coverSystemToUse;
        }
    }
コード例 #12
0
        void OnGUI()
        {
            if (m_style == null)
            {
                m_style = new EditorStyle();
                m_style.SetupStyle();
            }

            GUI.enabled = m_idle;
            EditorGUILayout.BeginVertical(m_style.GreyBox);
            m_style.DrawTitleBar("Required component (Motion Controller)");

            if (m_controller == null)
            {
                m_controller = (MotionController)EditorGUILayout.ObjectField(m_controller, typeof(MotionController), true);
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                GUI.enabled = false;
                EditorGUILayout.ObjectField(m_controller, typeof(MotionController), true);
                GUI.enabled = m_idle;
                if (GUILayout.Button("Unlock"))
                {
                    RemoveController();
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();

            if (m_controller == null)
            {
                Clips              = null;
                m_originalPos      = null;
                m_originalRot      = null;
                m_selectedPoseBase = 0;
                EditorGUILayout.HelpBox("Before setting up animations you must set all the required components, right now you are missing the Motion Controller component.", MessageType.Error);
                return;
            }

            if (!m_controller.Ready)
            {
                Clips = null;
                EditorGUILayout.HelpBox("Before setting up animations you must setup the Root bone and Legs of your Motion Controller.", MessageType.Error);
                return;
            }

            if (m_controller.Animator == null)
            {
                Clips = null;
                EditorGUILayout.HelpBox("The selected MotionController has no Animator component defined.", MessageType.Error);
                return;
            }

            if (m_controller.Animator.runtimeAnimatorController == null)
            {
                Clips = null;
                EditorGUILayout.HelpBox("The selected Animator GameObject has no AnimatorController.", MessageType.Error);
                return;
            }

            m_animator = m_controller.Animator;
            if (m_animator.avatar == null)
            {
                Clips = null;
                EditorGUILayout.HelpBox("The selected Animator GameObject has no Avatar.", MessageType.Error);
                return;
            }

            var rCtrl = m_animator.runtimeAnimatorController;

            if (rCtrl.animationClips == null || rCtrl.animationClips.Length == 0)
            {
                m_list = null;
                EditorGUILayout.HelpBox("AnimatorController has no animations, it should not be empty.", MessageType.Error);
                return;
            }

            m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos, false, false);
            EditorGUILayout.BeginVertical(m_style.GreyBox);
            m_style.DrawTitleBar("Animations from Animator Controller");

            if (Clips == null || Clips.Length == 0)
            {
                var clips = rCtrl.animationClips;
                Clips            = new MotionClip[clips.Length];
                m_animationPoses = new string[clips.Length];

                for (int i = 0; i < clips.Length; i++)
                {
                    var clip = clips[i];
                    m_animationPoses[i] = clip.name;

                    var m = new MotionClip()
                    {
                        Clip           = clip,
                        Id             = clip.GetInstanceID(),
                        Name           = clip.name,
                        FixFootSkating = false,
                    };
                    var nm = clip.name.ToLower();
                    if (nm.Contains("stand") || nm.Contains("idle"))
                    {
                        m.Stationary     = true;
                        m.FixFootSkating = true;
                    }

                    if (nm.Contains("walk") || nm.Contains("run") || nm.Contains("sprint") || nm.Contains("strafe"))
                    {
                        m.Stationary = false;
                    }

                    Clips[i] = m;
                }
            }

            m_so.Update();
            m_list.DoLayoutList();
            m_so.ApplyModifiedProperties();

            m_style.DrawTitleBar("Animation analisis");
            m_ignoreRootMotion = (IgnoreRootMotionOnBone)EditorGUILayout.EnumPopup("Ignore Root motion", m_ignoreRootMotion);
            m_selectedPoseBase = EditorGUILayout.Popup("Standing pose", m_selectedPoseBase, m_animationPoses);
            m_samples          = EditorGUILayout.IntSlider("Samples", m_samples, Int.Ten, Int.OneHundred);//EditorGUI.IntSlider(EditorGUILayout.GetControlRect(false, m_progHeight), "Samples", m_samples, Int.Ten, Int.OneHundred);

            if (m_idle)
            {
                if (!Clips[m_selectedPoseBase].Stationary)
                {
                    EditorGUILayout.HelpBox("Selected Standing pose is not Stationary.", MessageType.Error);
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Start analisis"))
                    {
                        StartProcess();
                    }
                    if (MotionAsset == null || MotionAsset.MotionCount == Int.Zero)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Save data"))
                    {
                        SaveAsset();
                    }

                    GUI.enabled = m_idle;
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                ProcessAnimation();
                string clipName;
                if (m_currentAnimation > -Int.One)
                {
                    clipName = Clips[m_currentAnimation].Name;
                }
                else
                {
                    clipName = Clips[Int.Zero].Name;
                }

                GUI.enabled = true;
                var prog = m_progress * Float.OneHundred;
                var sts  = prog.ToString("0") + "% " + clipName;
                if (m_progress >= Float.One)
                {
                    EditorGUI.ProgressBar(EditorGUILayout.GetControlRect(false, m_progHeight), m_progress, "Done");
                }
                else
                {
                    EditorGUI.ProgressBar(EditorGUILayout.GetControlRect(false, m_progHeight), m_progress, sts);
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();

            if (!m_idle && (m_uiDelay != m_lastUIDelay))
            {
                m_lastUIDelay = m_uiDelay;
                Repaint();
            }

            if (!m_idle && m_currentAnimation == (Clips.Length - Int.One))
            {
                m_uiDelay += Float.DotOne;
                if (m_uiDelay < Float.One)
                {
                    return;
                }

                m_idle = true;
                FinishAnalisis();
                SaveAsset();
                return;
            }

            if (m_reset)
            {
                MotionAsset = null;
                m_reset     = false;
            }
        }
コード例 #13
0
    private void DrawSetter()
    {
        GUILayout.Label(selectedAsset.id, Styles.SetterTitle, GUILayout.MaxHeight(25));
        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label("ID");
            GUILayout.Label(string.Format("<b>{0}</b> (#{1:X})", selectedAsset.id, selectedAsset.index), Styles.SetterFont);
        }
        EditorGUILayout.EndHorizontal();
        TexChar c = selectedChar;
        //        if (c.supported)
        {
            EditorGUILayout.BeginHorizontal();
            for (int i = 0; i < 2; i++)
            {
                if (GUILayout.Toggle(i == setterState, Styles.SetterHeaderContent[i], Styles.SetterHeader[i]))
                {
                    setterState = i;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUI.BeginChangeCheck();
            if (setterState == 0)
            {
                // Create an thumbnail
                switch (selectedAsset.type)
                {
                case TexAssetType.Font:
                    EditorGUILayout.LabelField(Styles.GetCharMapContent(selectedAsset.chars[selectedCharIdx].characterIndex),
                                               Styles.SetterPreview, GUILayout.Height(selectedFont.asset.lineHeight * 2.2f));
                    break;

                case TexAssetType.Sprite:
                    Rect r2 = EditorGUILayout.GetControlRect(GUILayout.Height(selectedSprite.lineHeight * EditorGUIUtility.labelWidth));
                    EditorGUI.LabelField(r2, GUIContent.none, Styles.SetterPreview);
                    r2.width *= .5f;
                    r2.x     += r2.width * .5f;

                    var sprt = selectedSprite.GenerateMetric(selectedChar.characterIndex);
                    GUI.DrawTextureWithTexCoords(r2, selectedSprite.Texture(), sprt.uv);
                    break;

#if TEXDRAW_TMP
                case TexAssetType.FontSigned:
                    r2 = EditorGUILayout.GetControlRect(GUILayout.Height(selectedSigned.LineHeight() * EditorGUIUtility.labelWidth));
                    EditorGUI.LabelField(r2, GUIContent.none, Styles.SetterPreview);
                    r2.width *= .5f;
                    r2.x     += r2.width * .5f;

                    sprt = selectedSigned.GenerateMetric(selectedChar.characterIndex);
                    GUI.DrawTextureWithTexCoords(r2, selectedSigned.asset.atlas, sprt.uv);
                    break;
#endif
                default:
                    break;
                }

                // Basic info stuff
                EditorGUILayout.LabelField("Index", string.Format("<b>{0}</b> (#{0:X2})", selectedCharIdx), Styles.SetterFont);
                EditorGUILayout.LabelField("Character Index", "<b>" +
                                           selectedChar.characterIndex.ToString() + "</b> (#" + ((int)selectedChar.characterIndex).ToString("X2")
                                           + ")", Styles.SetterFont);

                EditorGUILayout.LabelField("Symbol Definition");
                EditorGUILayout.BeginHorizontal();
                {
                    c.symbolAlt  = EditorGUILayout.TextField(c.symbolAlt);  //Secondary
                    c.symbolName = EditorGUILayout.TextField(c.symbolName); //Primary
                }
                EditorGUILayout.EndHorizontal();

                c.type = (CharType)EditorGUILayout.EnumPopup("Symbol Type", c.type);
                EditorGUILayout.LabelField("In math, this mapped as:");
                c.characterMap = EditorGUILayout.IntPopup(c.characterMap, Styles.SetterCharMap, Styles.SetterCharMapInt);
            }
            else
            {
                SetterScroll = EditorGUILayout.BeginScrollView(SetterScroll, GUILayout.ExpandHeight(true));
                {
                    EditorGUILayout.LabelField(string.Format("Hash \t : <b>{0}</b> (#{1:X1}{2:X2})", selectedFontIdx * 256 + selectedCharIdx, selectedFontIdx, selectedCharIdx), Styles.SetterFont);
                    c.nextLargerHash = SubDrawThumbnail(c.nextLargerHash, "Is Larger Character Exist?", Styles.SetterNextLarger);
                    EditorGUILayout.Space();
                    if (EditorGUILayout.ToggleLeft("Is Part of Extension?", c.extensionExist))
                    {
                        EditorGUI.indentLevel++;
                        c.extensionExist      = true;
                        c.extensionHorizontal = EditorGUILayout.ToggleLeft("Is This Horizontal?", c.extensionHorizontal);

                        c.extentTopHash    = SubDrawThumbnail(c.extentTopHash, c.extensionHorizontal ? "Has Left Extension?" : "Has Top Extension?", Styles.SetterExtendTop);
                        c.extentMiddleHash = SubDrawThumbnail(c.extentMiddleHash, "Has Middle Extension?", Styles.SetterExtendMiddle);
                        c.extentBottomHash = SubDrawThumbnail(c.extentBottomHash, c.extensionHorizontal ? "Has Right Extension?" : "Has Bottom Extension?", Styles.SetterExtendBottom);
                        c.extentRepeatHash = SubDrawThumbnail(c.extentRepeatHash, "Has Tiled Extension?", Styles.SetterExtendRepeat);

                        EditorGUI.indentLevel--;
                    }
                    else
                    {
                        c.extensionExist = false;
                    }
                }
                EditorGUILayout.EndScrollView();
            }
            if (EditorGUI.EndChangeCheck())
            {
                RecordDirty();
                lastCharChanged = true;
            }
        }
    }
コード例 #14
0
        private void OnGUI()
        {
            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, false, true);
            EditorGUILayout.LabelField("V 0.1");
            EditorGUILayout.LabelField("Pack different color channels of input textures and create a new texture. The Aspect Ratio of the input should match!", flowTextStyle);
            Divider();

            EditorGUILayout.LabelField("How to use:", UnityEditor.EditorStyles.boldLabel);
            EditorGUILayout.LabelField("1. Select your input textures.");
            EditorGUILayout.LabelField("2. Select the input channels you want to pack.");
            EditorGUILayout.LabelField("3. Select the target channels where you want to output.");
            EditorGUILayout.LabelField("4. Run the operation via \"Create Texture\".", flowTextStyle);
            EditorGUILayout.LabelField("Existing files will be overwritten!", UnityEditor.EditorStyles.boldLabel);

            Divider();
            EditorGUILayout.LabelField("Input:", UnityEditor.EditorStyles.boldLabel);
            PackerPopup(ref _sourceTexture0, ref _sourceChannel0, ref _targetChannel0, ref _targetChannelColor0);
            PackerPopup(ref _sourceTexture1, ref _sourceChannel1, ref _targetChannel1, ref _targetChannelColor1);
            PackerPopup(ref _sourceTexture2, ref _sourceChannel2, ref _targetChannel2, ref _targetChannelColor2);
            PackerPopup(ref _sourceTexture3, ref _sourceChannel3, ref _targetChannel3, ref _targetChannelColor3);
            Divider();

            EditorGUILayout.LabelField("Output Settings:", UnityEditor.EditorStyles.boldLabel);
            _outputFormat = (TextureFormat)EditorGUILayout.EnumPopup("Format", _outputFormat);
            EditorGUILayout.BeginHorizontal();
            float labelWidthBase = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 37;
            _outputWidth = EditorGUILayout.IntField("Width", _outputWidth);
            EditorGUIUtility.labelWidth = 42;
            _outputHeight = EditorGUILayout.IntField("Height", _outputHeight);
            EditorGUIUtility.labelWidth = labelWidthBase;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            _filePath = EditorGUILayout.TextField("Output Folder", _filePath);
            if (GUILayout.Button("Select"))
            {
                _filePath = EditorUtility.SaveFolderPanel("Output Folder", _filePath, "");
            }
            if (_filePath == "")
            {
                _filePath = _defaultFilePath;
            }
            EditorGUILayout.EndHorizontal();
            _filename = EditorGUILayout.TextField("Filename", _filename);

            Divider();

            EditorGUILayout.EndScrollView();

            bool oversized = _outputWidth >= 16384 || _outputHeight >= 16384;

            if (oversized)
            {
                EditorGUILayout.LabelField("Texture width or height is oversized.", UnityEditor.EditorStyles.boldLabel);
            }

            bool doubledChannelUsed = false;

            if (CheckDoubledOutputChannel(_targetChannel0) || CheckDoubledOutputChannel(_targetChannel1) ||
                CheckDoubledOutputChannel(_targetChannel2) || CheckDoubledOutputChannel(_targetChannel3))
            {
                doubledChannelUsed = true;
                EditorGUILayout.LabelField("Every output channel has to be unique.", UnityEditor.EditorStyles.boldLabel);
            }

            if (!doubledChannelUsed && !oversized && _filename != "")
            {
                if (GUILayout.Button("Create Texture"))
                {
                    EditorUtility.DisplayProgressBar("Texture progress", "Creating new texture...", 0.5f);
                    Texture2D _outputTexture = new Texture2D(_outputWidth, _outputHeight);

                    bool ra0 = false, ra1 = false, ra2 = false, ra3 = false;

                    if (_sourceTexture0)
                    {
                        ra0 = SetTextureReadable(_sourceTexture0);
                    }
                    if (_sourceTexture1)
                    {
                        ra1 = SetTextureReadable(_sourceTexture1);
                    }
                    if (_sourceTexture2)
                    {
                        ra2 = SetTextureReadable(_sourceTexture2);
                    }
                    if (_sourceTexture3)
                    {
                        ra3 = SetTextureReadable(_sourceTexture3);
                    }

                    for (int i = 0; i < _outputHeight; i++)
                    {
                        Vector2 pPos = new Vector2();
                        pPos.y = (float)i / (float)_outputHeight;

                        for (int j = 0; j < _outputWidth; j++)
                        {
                            pPos.x = (float)j / (float)_outputWidth;
                            Color pixelColor = Color.black, sourceRead0, sourceRead1, sourceRead2, sourceRead3;

                            sourceRead0 = ReadPixelValue(_sourceTexture0, pPos, _targetChannelColor0);
                            sourceRead1 = ReadPixelValue(_sourceTexture1, pPos, _targetChannelColor1);
                            sourceRead2 = ReadPixelValue(_sourceTexture2, pPos, _targetChannelColor2);
                            sourceRead3 = ReadPixelValue(_sourceTexture3, pPos, _targetChannelColor3);

                            PackColorChannelValueIntoChannel(sourceRead0, _sourceChannel0, _targetChannel0, ref pixelColor);
                            PackColorChannelValueIntoChannel(sourceRead1, _sourceChannel1, _targetChannel1, ref pixelColor);
                            PackColorChannelValueIntoChannel(sourceRead2, _sourceChannel2, _targetChannel2, ref pixelColor);
                            PackColorChannelValueIntoChannel(sourceRead3, _sourceChannel3, _targetChannel3, ref pixelColor);

                            _outputTexture.SetPixel(j, i, pixelColor);
                        }
                    }
                    _outputTexture.Apply();
                    SaveOutputTexture(_outputTexture, _filePath, FilterFilename(_filename), _outputFormat, _outputWidth >= _outputHeight ? _outputWidth : _outputHeight);

                    if (_sourceTexture0)
                    {
                        SetTextureReadable(_sourceTexture0, ra0);
                    }
                    if (_sourceTexture1)
                    {
                        SetTextureReadable(_sourceTexture1, ra1);
                    }
                    if (_sourceTexture2)
                    {
                        SetTextureReadable(_sourceTexture2, ra2);
                    }
                    if (_sourceTexture3)
                    {
                        SetTextureReadable(_sourceTexture3, ra3);
                    }

                    EditorUtility.ClearProgressBar();
                }
            }
        }
コード例 #15
0
        protected override void                                                    DisplayEditor()
        {
            DisplayEditorTop();
            ClassBuilder theObject = ((ClassBuilder)(object)selected);

            if (_intSelectedClass != theObject.ID)
            {
                _intSelectedClass = theObject.ID;
            }

            // DISPLAY THE UI
            if (_intSelected < 0 || !theObject.IsInitialized)
            {
                _intSelected = 0;                                                                                       //GetIndex(TypeArray, DBitemSlot.GetByID(theObject.SlotID).Name);
            }
            // DESCRIPTION
            EditorStyles.label.wordWrap = true;
            EditorGUILayout.LabelField("This Control allows you to create custom C# classes, " +
                                       "then builds all the necessary files (script, " +
                                       "editor and SQL Database scripts). The scripts can " +
                                       "then be found in the Directory below.");
            EditorGUILayout.Separator();

            _v2ScrollEPosition = EditorGUILayout.BeginScrollView(_v2ScrollEPosition, GUILayout.ExpandHeight(true));


            // CLASS NAME AND NAMESPACE
            EditorGUILayout.LabelField("Directory: ", "Assets/" + theObject.Script_Directory);
            theObject.ClassName = EditorGUILayout.TextField("Class Name: ", theObject.ClassName);

            if (!theObject.IsInitialized && theObject.ClassName != "" && GUILayout.Button("INITIALIZE CLASS"))
            {
                theObject.ResetVariables();
            }

            // DEFINE THE CLASS SETTINGS
            if (theObject.IsInitialized)
            {
                GUI.changed         = false;
                theObject.Namespace = EditorGUILayout.TextField("Namespace: ", theObject.Namespace);

                EditorGUILayout.Separator();
                EditorGUILayout.Space();

                EditorStyles.label.fontStyle = FontStyle.Bold;
                EditorGUILayout.LabelField("CONFIGURATION");
                EditorStyles.label.fontStyle = FontStyle.Normal;

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical();

                theObject.UseUnity = EditorGUILayout.Toggle("Uses Unity", theObject.UseUnity, GUILayout.Width(200));
                if (theObject.UseUnity)
                {
                    theObject.UseUnityUI = EditorGUILayout.Toggle("-- Uses Unity UI", theObject.UseUnityUI, GUILayout.Width(200));
                    if (!theObject.UseUnityUI)
                    {
                        theObject.UseUnityDatabase = false;
                    }
                    theObject.IsANetworkObject = EditorGUILayout.Toggle("-- Is Networked Object", theObject.IsANetworkObject, GUILayout.Width(200));
                    if (theObject.IsANetworkObject)
                    {
                        theObject.HasNetworkTransform = EditorGUILayout.Toggle("-- Has Net Transform", theObject.HasNetworkTransform, GUILayout.Width(200));
                    }
                    else
                    {
                        theObject.HasNetworkTransform = false;
                    }
                    if (!theObject.UseUnityDatabase)
                    {
                        theObject.UseEditor   = EditorGUILayout.Toggle("-- Create Inspector", theObject.UseEditor, GUILayout.Width(200));
                        theObject.UseClassMgr = EditorGUILayout.Toggle("-- Create Class Manager", theObject.UseClassMgr, GUILayout.Width(200));
                        if (theObject.UseEditor || theObject.UseClassMgr)
                        {
                            theObject.UseUnityDatabase = false;
                        }
                    }
                }
                else
                {
                    theObject.UseUnityUI          = false;
                    theObject.IsANetworkObject    = false;
                    theObject.HasNetworkTransform = false;
                    theObject.UseEditor           = false;
                    theObject.UseClassMgr         = false;
                    theObject.UseUnityDatabase    = false;
                }
                theObject.UseSerialization = EditorGUILayout.Toggle("-- Serializer/Deserializer", theObject.UseSerialization, GUILayout.Width(200));
                if (!theObject.UseSerialization)
                {
                    theObject.UseUnityDatabase = false;
                }

                if (theObject.UseUnity)
                {
                    EditorGUILayout.LabelField("Uses Other Managers (Singletons)");
                    theObject.UseAppMgr = EditorGUILayout.Toggle("-- ApplicationManager?", theObject.UseAppMgr, GUILayout.Width(200));
                    theObject.UseNetMgr = EditorGUILayout.Toggle("-- NetworkManager?", theObject.UseNetMgr, GUILayout.Width(200));
                }
                else
                {
                    theObject.UseAppMgr = false;
                    theObject.UseNetMgr = false;
                }

                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical();
                if (theObject.UseUnity)
                {
                    bool b = EditorGUILayout.Toggle("Uses Unity Database", theObject.UseUnityDatabase, GUILayout.Width(200));
                    if (b != theObject.UseUnityDatabase && b)
                    {
                        theObject.UseUnityDatabase = true;
                        theObject.UseUnityUI       = true;
                        theObject.UseSerialization = true;
                        theObject.UseSQLDatabase   = false;
                        theObject.UseEditor        = false;
                        theObject.UseClassMgr      = false;
                    }
                }

                theObject.UseSQLDatabase = EditorGUILayout.Toggle("Uses SQL Database", theObject.UseSQLDatabase, GUILayout.Width(200));
                if (theObject.UseSQLDatabase)
                {
                    theObject.UseUnityDatabase = false;
                }

                if (theObject.UseUnity)
                {
                    if (theObject.UseSQLDatabase)
                    {
                        theObject.UseDBmgr = EditorGUILayout.Toggle("-- DatabaseManager?", theObject.UseDBmgr, GUILayout.Width(200));
                    }
                    else
                    {
                        theObject.UseDBmgr = false;
                    }
                }
                else
                {
                    theObject.UseDBmgr = false;
                }
                if (theObject.UseSQLDatabase)
                {
                    theObject.UseDBload = EditorGUILayout.Toggle("-- Handle Loads", theObject.UseDBload, GUILayout.MinWidth(200));
                    theObject.UseDBsave = EditorGUILayout.Toggle("-- Handle Saves", theObject.UseDBsave, GUILayout.MinWidth(200));
                }
                else
                {
                    theObject.UseDBload = false;
                    theObject.UseDBsave = false;
                }
                EditorGUILayout.Separator();

                if (!theObject.UseDBmgr && theObject.UseSQLDatabase)
                {
                    EditorGUILayout.LabelField("MS-SQL SERVER SET UP");
                    theObject.DBserver        = EditorGUILayout.TextField("Server", theObject.DBserver);
                    theObject.DBdatabase      = EditorGUILayout.TextField("Database", theObject.DBdatabase);
                    theObject.DBuseWinAccount = EditorGUILayout.Toggle("Use Windows User Acct", theObject.DBuseWinAccount);
                    if (!theObject.DBuseWinAccount)
                    {
                        theObject.DBuser     = EditorGUILayout.TextField("Username", theObject.DBuser);
                        theObject.DBpassword = EditorGUILayout.PasswordField("Password", theObject.DBpassword);
                    }
                    else
                    {
                        theObject.DBuser     = "";
                        theObject.DBpassword = "";
                    }
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Separator();
                EditorGUILayout.Space();

                // ADD A NEW PROPERTY
                // -- CONTENT
                EditorGUILayout.BeginHorizontal();
                EditorStyles.label.fontStyle = FontStyle.Bold;
                EditorGUILayout.LabelField("CREATE NEW CLASS FIELD");
                EditorStyles.label.fontStyle = FontStyle.Normal;
                if (GUILayout.Button("OPEN ENUM EDITOR"))
                {
                    EnumBuilderDatabaseEditor.Init();
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                // ---- FIELD NAME
                EditorGUILayout.BeginVertical();
                EditorStyles.label.richText     = true;
                EditorStyles.label.stretchWidth = false;
                EditorGUILayout.LabelField("\n<color=yellow>Field Name</color>", GUILayout.Width(100), GUILayout.Height(32));
                EditorStyles.label.richText     = false;
                EditorStyles.label.stretchWidth = true;
                _strNewVar = EditorGUILayout.TextField("", _strNewVar, GUILayout.Width(100));
                _strNewVar = Regex.Replace(_strNewVar, @"[^a-zA-Z0-9_]", "");
                EditorGUILayout.EndVertical();

                // ---- FIELD TYPE
                EditorGUILayout.BeginVertical();
                EditorStyles.label.richText     = true;
                EditorStyles.label.stretchWidth = false;
                EditorGUILayout.LabelField("\n<color=yellow>Type</color>", GUILayout.Width(75), GUILayout.Height(32));
                EditorStyles.label.richText     = false;
                EditorStyles.label.stretchWidth = true;
                int iSlot = EditorGUILayout.Popup("", _intSelected, TypeArray, GUILayout.Width(75));
                if (iSlot != _intSelected)
                {
                    _strNewType  = TypeArray[iSlot];
                    _intSelected = iSlot;
                }
                EditorGUILayout.EndVertical();

                // ---- MAXIMUM LENGTH (FOR STRING ONLY)
                EditorGUILayout.BeginVertical();
                EditorStyles.label.richText     = true;
                EditorStyles.label.stretchWidth = false;
                EditorGUILayout.LabelField("\n<color=yellow>MaxLn</color>", GUILayout.Width(40), GUILayout.Height(32));
                EditorStyles.label.richText     = false;
                EditorStyles.label.stretchWidth = true;
                if (_strNewType == "string")
                {
                    _intMaxLen = EditorGUILayout.IntField("", _intMaxLen, GUILayout.Width(40));
                }
                else
                {
                    EditorGUILayout.LabelField(" ", GUILayout.Width(40));
                }
                EditorGUILayout.EndVertical();

                // ---- DEFAULT STARTING VALUE
                EditorGUILayout.BeginVertical();
                EditorStyles.label.richText     = true;
                EditorStyles.label.stretchWidth = false;
                if (_intSelected == 4)
                {
                    EditorGUILayout.LabelField("\n<color=yellow>Enum Type</color>", GUILayout.Width(150), GUILayout.Height(32));
                }
                else
                {
                    EditorGUILayout.LabelField("\n<color=yellow>Default Value</color>", GUILayout.Width(150), GUILayout.Height(32));
                }
                EditorStyles.label.richText     = false;
                EditorStyles.label.stretchWidth = true;
                switch (_intSelected)
                {
                case 0:                                         // "int":
                    int x = EditorGUILayout.IntField("", intTemp, GUILayout.Width(150));
                    if (x != intTemp)
                    {
                        _strStart = x.ToString();
                        intTemp   = x;
                    }
                    break;

                case 1:                                         // "string":
                    string s = EditorGUILayout.TextField("", strTemp, GUILayout.Width(150));
                    if (s != strTemp)
                    {
                        _strStart = s.ToString();
                        strTemp   = s;
                    }
                    break;

                case 2:                                         // "bool":
                    bool bln = EditorGUILayout.Toggle("", blnTemp, GUILayout.Width(150));
                    if (bln != blnTemp)
                    {
                        _strStart = bln.ToString().ToLower();
                        blnTemp   = bln;
                    }
                    break;

                case 3:                                         // "float":
                    float f = EditorGUILayout.FloatField("", fTemp, GUILayout.Width(150));
                    if (f != fTemp)
                    {
                        _strStart = f.ToString();
                        fTemp     = f;
                    }
                    break;

                case 4:                                         // "enum"
                    int iEnum = EditorGUILayout.Popup("", _intSelectedEnum, EnumArray, GUILayout.Width(150));
                    if (iEnum != _intSelectedEnum)
                    {
                        _strNewType      = "enum" + EnumArray[iEnum];
                        _intSelectedEnum = iEnum;
                        _strEnumDefList  = CreateEnumDefaultPopUpListByID(DBenums, iEnum);
                    }
                    if (_intSelectedEnum >= 0 && EnumDefaultArray != null && EnumDefaultArray.Length > 0)
                    {
                        int e = EditorGUILayout.Popup("", intTemp, EnumDefaultArray, GUILayout.Width(150));
                        if (e != intTemp)
                        {
                            _strStart = e.ToString();
                            intTemp   = e;
                        }
                    }
                    break;

                case 5:                                         // "date" "datetime"
                    string d = EditorGUILayout.TextField("", dtTemp, GUILayout.Width(150));
                    try
                    {
                        if (Util.IsDate(d))
                        {
                            System.DateTime dx = Util.ConvertToDate(d);
                            if (dx.ToString("MM/dd/yyyy HH:mm:ss") != dtTemp)
                            {
                                _strStart = dx.ToString("MM/dd/yyyy HH:mm:ss");
                                dtTemp    = _strStart;
                            }
                        }
                        else
                        {
                            dtTemp = "";
                        }
                    } catch {
                        Debug.LogError("DateTime Error");
                        dtTemp = "";
                    }
                    break;

                case 6:                                         // "vector2":
                    Vector2 v2 = EditorGUILayout.Vector2Field("", v2Temp, GUILayout.Width(150));
                    if (v2 != v2Temp)
                    {
                        _strStart = v2.ToString();
                        v2Temp    = v2;
                    }
                    break;

                case 7:                                         // "vector3":
                    Vector3 v3 = EditorGUILayout.Vector3Field("", v3Temp, GUILayout.Width(150));
                    if (v3 != v3Temp)
                    {
                        _strStart = v3.ToString();
                        v3Temp    = v3;
                    }
                    break;

                case 8:                                         // "quaternion":
                    Vector4 v4 = EditorGUILayout.Vector4Field("", v4Temp, GUILayout.Width(150));
                    if (v4 != v4Temp)
                    {
                        Quaternion q = Quaternion.identity;
                        q.x       = v4.x;
                        q.y       = v4.y;
                        q.z       = v4.z;
                        q.w       = v4.w;
                        _strStart = q.ToString();
                        v4Temp    = v4;
                    }
                    break;

                case 9:                                         // "sprite"
                    break;
                }
                EditorGUILayout.EndVertical();

                // ---- CAN SEARCH ON
                EditorGUILayout.BeginVertical();
                EditorStyles.label.richText     = true;
                EditorStyles.label.stretchWidth = false;
                EditorGUILayout.LabelField("<color=yellow>Can\nFind</color>", GUILayout.Width(40), GUILayout.Height(32));
                EditorStyles.label.richText     = false;
                EditorStyles.label.stretchWidth = true;
                _blnNewFind = EditorGUILayout.Toggle("", _blnNewFind, GUILayout.Width(40)) && !(_intSelected == 9);
                EditorGUILayout.EndVertical();

                // ---- IS NETWORKED OBJECT -- SYNCVAR
                if (theObject.IsANetworkObject)
                {
                    EditorGUILayout.BeginVertical();
                    EditorStyles.label.richText     = true;
                    EditorStyles.label.stretchWidth = false;
                    EditorGUILayout.LabelField("<color=yellow>Sync\nVar</color>", GUILayout.Width(40), GUILayout.Height(32));
                    EditorStyles.label.richText     = false;
                    EditorStyles.label.stretchWidth = true;
                    _blnSyncVar = EditorGUILayout.Toggle("", _blnSyncVar, GUILayout.Width(40)) && !(_intSelected == 9);
                    EditorGUILayout.EndVertical();
                }

                // ---- IS NAME OF THE OBJECT
                EditorGUILayout.BeginVertical();
                EditorStyles.label.richText     = true;
                EditorStyles.label.stretchWidth = false;
                EditorGUILayout.LabelField("<color=yellow>Obj\nName</color>", GUILayout.Width(40), GUILayout.Height(32));
                EditorStyles.label.richText     = false;
                EditorStyles.label.stretchWidth = true;
                if (theObject.HasNamedVariable)
                {
                    _blnIsName = false;
                    EditorGUILayout.Toggle("", false, GUILayout.Width(40));
                }
                else
                {
                    _blnIsName = EditorGUILayout.Toggle("", _blnIsName, GUILayout.Width(40)) && !(_intSelected == 9);
                }
                EditorGUILayout.EndVertical();

                // ---- ADD BUTTON
                EditorGUILayout.BeginVertical();
                EditorStyles.label.richText     = true;
                EditorStyles.label.stretchWidth = false;
                EditorGUILayout.LabelField("", GUILayout.Width(75), GUILayout.Height(32));
                EditorStyles.label.richText     = false;
                EditorStyles.label.stretchWidth = true;
                int    intVariableExists = theObject.Variables.FindIndex(x => x.Name.ToLower() == _strNewVar.Trim().ToLower());
                bool   blnVariableExists = false;
                string strAddVarBtnName  = "ADD";
                if (theObject.Variables.Count > 0 && intVariableExists >= 0 &&
                    !theObject.Variables[intVariableExists].IsIndex && !theObject.Variables[intVariableExists].IsMandatory)
                {
                    strAddVarBtnName  = "UPDATE";
                    blnVariableExists = true;
                }
                if (GUILayout.Button(strAddVarBtnName, GUILayout.Width(75)) && _strNewVar != "" &&
                    (_intSelected != 4 || (_intSelected == 4 && _intSelectedEnum >= 0)) &&
                    (blnVariableExists || (!blnVariableExists && theObject.Variables.FindAll(x => x.Name.ToLower() == _strNewVar.ToLower()).Count < 1)) &&
                    DBenums.GetByName(_strNewVar) == null)
                {
                    if (_strNewType == "")
                    {
                        _strNewType = "int";
                    }
                    ClassBuilder.ClassProperty prop = new ClassBuilder.ClassProperty();
                    prop.Name          = _strNewVar;
                    prop.MaxLength     = _intMaxLen;
                    prop.VarType       = _strNewType;
                    prop.StartingValue = _strStart;
                    prop.IsSearchable  = _blnNewFind;
                    prop.IsSynchVar    = _blnSyncVar;
                    prop.IsNameVar     = _blnIsName;
                    if (blnVariableExists)
                    {
                        theObject.Variables[intVariableExists].Deserialize(prop.Serialize());
                    }
                    else
                    {
                        theObject.AddProperty(prop);
                    }
                    blnVariableExists = false;
                    _strNewVar        = "";
                    _strNewType       = "int";
                    _strStart         = "";
                    _intMaxLen        = 20;
                    _intSelected      = -1;
                    _intSelectedEnum  = -1;
                    _blnSyncVar       = false;

                    strTemp = "";
                    intTemp = 0;
                    fTemp   = 0;
                    blnTemp = false;
                    v2Temp  = Vector2.zero;
                    v3Temp  = Vector3.zero;
                    v4Temp  = Vector4.zero;
                    dtTemp  = "";
                    GUI.FocusControl(null);
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Separator();
                EditorGUILayout.Space();

                // LIST CLASS PROPERTIES
                // -- HEADER
                EditorStyles.label.fontStyle = FontStyle.Bold;
                EditorGUILayout.LabelField("CURRENT CLASS FIELDS");
                EditorStyles.label.fontStyle = FontStyle.Normal;
                EditorGUILayout.BeginHorizontal();
                EditorStyles.label.richText     = true;
                EditorStyles.label.stretchWidth = false;
                GUILayout.Button(" ", GUILayout.Width(20), GUILayout.MaxWidth(20));
                EditorGUILayout.LabelField("\n<color=yellow>Field Name</color>", GUILayout.Width(125), GUILayout.Height(32));
                EditorGUILayout.LabelField("\n<color=yellow>Type</color>", GUILayout.Width(75), GUILayout.Height(32));
                EditorGUILayout.LabelField("\n<color=yellow>MaxLn</color>", GUILayout.Width(40), GUILayout.Height(32));
                EditorGUILayout.LabelField("<color=yellow>Can\nFind</color>", GUILayout.Width(40), GUILayout.Height(32));
                if (theObject.IsANetworkObject)
                {
                    EditorGUILayout.LabelField("<color=yellow>Sync\nVar</color>", GUILayout.Width(40), GUILayout.Height(32));
                }
                EditorGUILayout.LabelField("<color=yellow>Obj\nName</color>", GUILayout.Width(40), GUILayout.Height(32));
                EditorGUILayout.LabelField("\n<color=yellow>Default Value</color>", GUILayout.Width(125), GUILayout.Height(32));
                EditorStyles.label.richText     = false;
                EditorStyles.label.stretchWidth = true;
                EditorGUILayout.EndHorizontal();

                // -- CONTENT
                EditorGUILayout.BeginVertical();
                Color defaultColor   = GUI.color;
                Color defaultBGcolor = GUI.backgroundColor;
                for (int i = 0; i < theObject.Variables.Count; i++)
                {
                    bool blnHighlight = blnVariableExists && _strNewVar.Trim().ToLower() == theObject.Variables[i].Name.ToLower();
                    if (!theObject.Variables[i].IsDeleted)
                    {
                        EditorGUILayout.BeginHorizontal();

                        if (blnHighlight)
                        {
                            GUI.color           = Color.green;
                            GUI.backgroundColor = Color.cyan;
                        }

                        if (!theObject.Variables[i].IsIndex && !theObject.Variables[i].IsMandatory)
                        {
                            if (GUILayout.Button("X", GUILayout.Width(20), GUILayout.MaxWidth(20)))
                            {
                                if (EditorUtility.DisplayDialog("Delete this Property?", "Are you sure that you want to delete \"" + theObject.Variables[i].Name + "\"?", "Delete", "Cancel"))
                                {
                                    theObject.Variables[i].IsDeleted = true;
                                }
                            }
                        }
                        else
                        {
                            GUILayout.Button(" ", GUILayout.Width(20), GUILayout.MaxWidth(20));
                        }
                        EditorGUILayout.LabelField(theObject.Variables[i].Name, GUILayout.Width(125));

                        if (theObject.Variables[i].VarType.ToLower().StartsWith("enum"))
                        {
                            EditorGUILayout.LabelField(theObject.Variables[i].VarType.Substring(4), GUILayout.Width(75));
                        }
                        else
                        {
                            EditorGUILayout.LabelField(theObject.Variables[i].VarType, GUILayout.Width(75));
                        }

                        if (theObject.Variables[i].VarType.ToLower() == "string")
                        {
                            EditorGUILayout.LabelField(theObject.Variables[i].MaxLength.ToString(), GUILayout.Width(40));
                        }
                        else
                        {
                            EditorGUILayout.LabelField("", GUILayout.Width(40));
                        }

                        EditorGUILayout.Toggle(theObject.Variables[i].IsSearchable, GUILayout.Width(40));

                        if (theObject.IsANetworkObject)
                        {
                            EditorGUILayout.Toggle(theObject.Variables[i].IsSynchVar, GUILayout.Width(40));
                        }

                        EditorGUILayout.Toggle(theObject.Variables[i].IsNameVar, GUILayout.Width(40));

                        if (theObject.Variables[i].VarType.ToLower().StartsWith("enum"))
                        {
                            string sV = theObject.Variables[i].VarType.Substring(4).ToLower();
                            int    w  = DBenums.database.FindIndex(x => x.Name.ToLower() == sV);
                            if (w >= 0)
                            {
                                EditorGUILayout.LabelField(CreateEnumDefaultPopUpListByID(DBenums, w)[Util.ConvertToInt(theObject.Variables[i].StartingValue)], GUILayout.Width(125));
                            }
                        }
                        else
                        {
                            EditorGUILayout.LabelField(theObject.Variables[i].StartingValue, GUILayout.Width(125));
                        }

                        GUI.color           = defaultColor;
                        GUI.backgroundColor = defaultBGcolor;

                        EditorGUILayout.EndHorizontal();
                    }
                }
                EditorGUILayout.EndVertical();

                // CREATE BUTTON
                EditorGUILayout.Space();

                if (GUI.changed)
                {
                    _blnNote = false;
                }

                if (Application.isPlaying && false)
                {
                    EditorGUILayout.Space();
                    if (theObject.UseSQLDatabase && theObject.Variables.Count > 0 && GUILayout.Button("MODIFY DATABASE"))
                    {
                        _blnNote = theObject.CreateSQLscriptsIntoSQLdatabase();
                    }
                }
            }
            EditorGUILayout.EndScrollView();

            GUILayout.EndVertical();
            GUILayout.Space(10);

            if (_blnNote)
            {
                EditorGUILayout.LabelField("Files have been successfully Generated.");
                GUILayout.Space(5);
            }

            if (theObject.Variables.Count > 0 && GUILayout.Button("GENERATE CLASS FILES"))
            {
                theObject.GenerateClass();
                _blnNote = true;
            }
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("SAVE"))
            {
                if (selected != null && selected.Name.Trim() != "")
                {
                    ((BaseDatabase <ClassBuilder>)(object) editorDB).Save(theObject);
                    selected = null;
                    GUI.FocusControl("");
                }
            }

            DisplayEditorBottom();
        }
コード例 #16
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            tweenPath.IsClosedLoop = EditorGUILayout.Toggle("Closed Loop", tweenPath.IsClosedLoop);
            serializedObject.FindProperty("isClosedLoop").boolValue = tweenPath.IsClosedLoop;
            serializedObject.ApplyModifiedProperties();

            tweenPath.ApplyRootTransform = EditorGUILayout.Toggle("Apply Root Transform", tweenPath.ApplyRootTransform);
            serializedObject.FindProperty("applyRootTransform").boolValue = tweenPath.ApplyRootTransform;
            serializedObject.ApplyModifiedProperties();

            tweenPath.ExamplePosition = (GameObject)EditorGUILayout.ObjectField("TestPosition",
                                                                                tweenPath.ExamplePosition, typeof(GameObject), true);
            var bigGs = new GUIStyle(GetRichTextGuiStyle());

            bigGs.fontSize = 16;
            if (list == null)
            {
                Init();
            }

            #region Curve Nodes

            GUILayout.Label("nodes", bigGs);
            var listHeight = Mathf.Min(200, list.GetHeight());
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(listHeight));
            list.DoLayoutList();
            EditorGUILayout.EndScrollView();

            #endregion

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            #region Scene View Editor Options

            GUILayout.Label("节点编辑配置", bigGs);
            GUILayout.BeginHorizontal();
//            svOriginAxisLock = GUILayout.Toggle(svOriginAxisLock, "Origin Axis Lock", "button");
//            svHandlesAxisLock = GUILayout.Toggle(svHandlesAxisLock, "Handles Axis Lock", "button");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            svLockX = GUILayout.Toggle(svLockX, "Lock X Axis", "button");
            svLockY = GUILayout.Toggle(svLockY, "Lock Y Axis", "button");
            svLockZ = GUILayout.Toggle(svLockZ, "Lock Z Axis", "button");
            GUILayout.EndHorizontal();

            #endregion

            GUILayout.Label("edit mode", bigGs);
            editMode = (emEditMode)GUILayout.Toolbar((int)editMode,
                                                     new[] { emEditMode.Root.ToString(), emEditMode.Single.ToString(), emEditMode.ALL.ToString() },
                                                     "button");

            #region Simulation

            // 样本目标体进度
//            simulationIndex = EditorGUILayout.IntSlider("Demo Progress", simulationIndex, -1, 100);

//            GUILayout.BeginHorizontal();
//            simulateDuration = EditorGUILayout.FloatField("Duration", simulateDuration);
//            if (GUILayout.Button("Demonstrate"))
//            {
//                simulateTime = 0;
//                simulateDateTime = DateTime.Now;
//            }
//            GUILayout.EndHorizontal();

            #endregion

            EditorUtility.SetDirty(tweenPath);
        }
コード例 #17
0
        void OnGUI()
        {
            GUILayout.Space(10);

            m_bakeSetName = EditorGUILayout.TextField(m_bakeSetName);

            m_forceAllLights = EditorGUILayout.ToggleLeft(Styles.m_bakeAllLights, m_forceAllLights);

            if (m_groups == null)
            {
                CloseDialog();
                m_resultCallback(Result.Cancel, m_bakeSetName, null, m_activeSet, m_forceAllLights);
            }

            if (!m_forceAllLights)
            {
                EditorGUILayout.LabelField(Styles.m_lightGroups);

                m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition);
                {
                    // 'ungrouped' lights under root
                    List <Light> rootLights = null;
                    if (m_groups.TryGetValue(Constants.kRoot, out rootLights))
                    {
                        for (int i = 0; i < rootLights.Count; ++i)
                        {
                            EditorGUILayout.BeginHorizontal();
                            GUILayout.Space(10);
                            EditorGUILayout.LabelField(rootLights[i].name, Styles.m_ungroupedStyle);

                            int idInFile = rootLights[i].GetLocalIDinFile();
                            // search to see if light already exists in the list
                            bool included = m_selectedLights.Exists(delegate(LightEntry obj)
                            {
                                // find by object reference
                                return(obj.m_idInFile == idInFile);
                            });

                            // Create UI and list for toggle
                            if (EditorGUILayout.Toggle(included))
                            {
                                // added - toggle was checked and the item was not already selected
                                if (!included)
                                {
                                    m_selectedLights.Add(new LightEntry(rootLights[i], null));
                                }
                            }
                            else
                            {
                                // was included - it was unchecked and was previously selected so it needs to be removed
                                if (included)
                                {
                                    m_selectedLights.RemoveAll(delegate(LightEntry obj)
                                    {
                                        // find by object reference
                                        return(obj.m_idInFile == idInFile);
                                    });
                                }
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }

                    // Lights contained under a parent group
                    Dictionary <string, List <Light> > .Enumerator iter = m_groups.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        string groupPath = iter.Current.Key;
                        if (groupPath == Constants.kRoot)
                        {
                            continue;
                        }


                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Space(10);
                        GUIContent groupName = new GUIContent(groupPath, "Lights grouped by parent");
                        EditorGUILayout.LabelField(groupName, Styles.m_groupedStyle);

                        // search for group path
                        bool included = m_selectedLights.Exists(delegate(LightEntry obj) {
                            return(obj.m_group == groupPath);
                        });

                        if (EditorGUILayout.Toggle(included))
                        {
                            // added
                            if (!included)
                            {
                                // add new group path
                                m_selectedLights.Add(new LightEntry(null, groupPath));
                            }
                        }
                        else
                        {
                            // was included
                            if (included)
                            {
                                int idx = m_selectedLights.FindIndex(delegate(LightEntry obj)
                                {
                                    return(obj.m_group == groupPath);
                                });

                                if (idx >= 0)
                                {
                                    m_selectedLights.RemoveAt(idx);
                                }
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
                EditorGUILayout.EndScrollView();
            }

            GUILayout.Space(20);

            m_activeSet = EditorGUILayout.ToggleLeft(Styles.m_activeBake, m_activeSet);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("OK"))
            {
                m_resultCallback(Result.Ok, m_bakeSetName, m_selectedLights, m_activeSet, m_forceAllLights);
                CloseDialog();
            }
            if (GUILayout.Button("Cancel"))
            {
                m_resultCallback(Result.Cancel, m_bakeSetName, m_selectedLights, m_activeSet, m_forceAllLights);
                CloseDialog();
            }
            EditorGUILayout.EndHorizontal();

            BakeSets bakeSets = BakeData.Instance().GetBakeSets();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (bakeSets.m_containers.Count > 0 && GUILayout.Button(Styles.m_clearBakeData, Styles.m_clearButton))
            {
                if (EditorUtility.DisplayDialog(m_bakeSetName, "Clear data, are you sure?", "Yes", "No"))
                {
                    for (int i = 0, k = bakeSets.m_containers.Count; i < k; ++i)
                    {
                        if (bakeSets.m_containers[i].m_bakeSetId == m_bakeSetName)
                        {
                            List <Mesh> meshes = bakeSets.m_containers[i].m_list;
                            for (int j = 0; j < meshes.Count; ++j)
                            {
                                DestroyImmediate(meshes[j], true);
                            }
                            break;
                        }
                    }
                }

                EditorUtility.SetDirty(bakeSets);
                AssetDatabase.SaveAssets();
            }
            GUILayout.EndHorizontal();
        }
コード例 #18
0
#pragma warning restore 618
        public static void PreferencesGUI()
        {
            bool preferencesChangedThisFrame = false;

            EditorGUILayout.LabelField($"Version: {NuGetForUnityVersion}");

            if (NugetHelper.NugetConfigFile == null)
            {
                NugetHelper.LoadNugetConfigFile();
            }

            Debug.Assert(NugetHelper.NugetConfigFile != null, "NugetHelper.NugetConfigFile != null");
            bool installFromCache = EditorGUILayout.Toggle("Install From the Cache", NugetHelper.NugetConfigFile.InstallFromCache);

            if (installFromCache != NugetHelper.NugetConfigFile.InstallFromCache)
            {
                preferencesChangedThisFrame = true;
                NugetHelper.NugetConfigFile.InstallFromCache = installFromCache;
            }

            bool readOnlyPackageFiles = EditorGUILayout.Toggle("Read-Only Package Files", NugetHelper.NugetConfigFile.ReadOnlyPackageFiles);

            if (readOnlyPackageFiles != NugetHelper.NugetConfigFile.ReadOnlyPackageFiles)
            {
                preferencesChangedThisFrame = true;
                NugetHelper.NugetConfigFile.ReadOnlyPackageFiles = readOnlyPackageFiles;
            }

            bool verbose = EditorGUILayout.Toggle("Use Verbose Logging", NugetHelper.NugetConfigFile.Verbose);

            if (verbose != NugetHelper.NugetConfigFile.Verbose)
            {
                preferencesChangedThisFrame         = true;
                NugetHelper.NugetConfigFile.Verbose = verbose;
            }

            EditorGUILayout.LabelField("Package Sources:");

            _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);

            NugetPackageSource sourceToMoveUp   = null;
            NugetPackageSource sourceToMoveDown = null;
            NugetPackageSource sourceToRemove   = null;

            foreach (var source in NugetHelper.NugetConfigFile.PackageSources)
            {
                EditorGUILayout.BeginVertical();
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.BeginVertical(GUILayout.Width(20));
                        {
                            GUILayout.Space(10);
                            bool isEnabled = EditorGUILayout.Toggle(source.IsEnabled, GUILayout.Width(20));
                            if (isEnabled != source.IsEnabled)
                            {
                                preferencesChangedThisFrame = true;
                                source.IsEnabled            = isEnabled;
                            }
                        }
                        EditorGUILayout.EndVertical();

                        EditorGUILayout.BeginVertical();
                        {
                            string name = EditorGUILayout.TextField(source.Name);
                            if (name != source.Name)
                            {
                                preferencesChangedThisFrame = true;
                                source.Name = name;
                            }

                            string savedPath = EditorGUILayout.TextField(source.SavedPath).Trim();
                            if (savedPath != source.SavedPath)
                            {
                                preferencesChangedThisFrame = true;
                                source.SavedPath            = savedPath;
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(29);
                        EditorGUIUtility.labelWidth = 75;
                        EditorGUILayout.BeginVertical();

                        bool hasPassword = EditorGUILayout.Toggle("Credentials", source.HasPassword);
                        if (hasPassword != source.HasPassword)
                        {
                            preferencesChangedThisFrame = true;
                            source.HasPassword          = hasPassword;
                        }

                        if (source.HasPassword)
                        {
                            string userName = EditorGUILayout.TextField("User Name", source.UserName);
                            if (userName != source.UserName)
                            {
                                preferencesChangedThisFrame = true;
                                source.UserName             = userName;
                            }

                            string savedPassword = EditorGUILayout.PasswordField("Password", source.SavedPassword);
                            if (savedPassword != source.SavedPassword)
                            {
                                preferencesChangedThisFrame = true;
                                source.SavedPassword        = savedPassword;
                            }
                        }
                        else
                        {
                            source.UserName = null;
                        }
                        EditorGUIUtility.labelWidth = 0;
                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        if (GUILayout.Button("Move Up"))
                        {
                            sourceToMoveUp = source;
                        }

                        if (GUILayout.Button("Move Down"))
                        {
                            sourceToMoveDown = source;
                        }

                        if (GUILayout.Button("Remove"))
                        {
                            sourceToRemove = source;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.EndVertical();
            }

            if (sourceToMoveUp != null)
            {
                int index = NugetHelper.NugetConfigFile.PackageSources.IndexOf(sourceToMoveUp);
                if (index > 0)
                {
                    NugetHelper.NugetConfigFile.PackageSources[index]     = NugetHelper.NugetConfigFile.PackageSources[index - 1];
                    NugetHelper.NugetConfigFile.PackageSources[index - 1] = sourceToMoveUp;
                }
                preferencesChangedThisFrame = true;
            }

            if (sourceToMoveDown != null)
            {
                int index = NugetHelper.NugetConfigFile.PackageSources.IndexOf(sourceToMoveDown);
                if (index < NugetHelper.NugetConfigFile.PackageSources.Count - 1)
                {
                    NugetHelper.NugetConfigFile.PackageSources[index]     = NugetHelper.NugetConfigFile.PackageSources[index + 1];
                    NugetHelper.NugetConfigFile.PackageSources[index + 1] = sourceToMoveDown;
                }
                preferencesChangedThisFrame = true;
            }

            if (sourceToRemove != null)
            {
                NugetHelper.NugetConfigFile.PackageSources.Remove(sourceToRemove);
                preferencesChangedThisFrame = true;
            }

            if (GUILayout.Button("Add New Source"))
            {
                NugetHelper.NugetConfigFile.PackageSources.Add(new NugetPackageSource("New Source", "source_path"));
                preferencesChangedThisFrame = true;
            }

            EditorGUILayout.EndScrollView();

            if (GUILayout.Button("Reset To Default"))
            {
                NugetConfigFile.CreateDefaultFile(NugetHelper.NugetConfigFilePath);
                NugetHelper.LoadNugetConfigFile();
                preferencesChangedThisFrame = true;
            }

            if (preferencesChangedThisFrame)
            {
                NugetHelper.NugetConfigFile.Save(NugetHelper.NugetConfigFilePath);
            }
        }
コード例 #19
0
	void OnGUI () {
		if(parentEditor!=null)
		{
			ScrollPositionBattleEditor=EditorGUILayout.BeginScrollView(ScrollPositionBattleEditor);
			if(parentEditor.TinkerPlayer_1.Count>0&&parentEditor.TinkerPlayer_2.Count>0)
			{
				if(Battle)
				{
					if(GUILayout.Button("OPEN HERO TURN LIST"))
					{
						if(!OpenWindow)
						{
							Open_Hero_Turns();
							OpenWindow=!OpenWindow;
						}	
					}
					if(temp.Count==0 && temp2.Count==0 && HEROTURNORDER.Count==0)
					{
						temp=parentEditor.OrderTurnListbySpeed(parentEditor.TinkerPlayer_1);
						temp2=parentEditor.OrderTurnListbySpeed(parentEditor.TinkerPlayer_2);

						HEROTURNORDER.AddRange(temp);
						HEROTURNORDER.AddRange(temp2);
						HEROTURNORDER=parentEditor.OrderTurnListbySpeed(HEROTURNORDER);
					}

					if(HEROTURNORDER.Count>0)
					{
						P1_Turn=CheckingTurn(temp,HEROTURNORDER[0]);
						P2_Turn=CheckingTurn(temp2,HEROTURNORDER[0]);
					}
					else
					{
						HEROTURNORDER.AddRange(temp);
						HEROTURNORDER.AddRange(temp2);
						HEROTURNORDER=parentEditor.OrderTurnListbySpeed(HEROTURNORDER);
						for(int x=0;x<HEROTURNORDER.Count;x++)
						{
							if(HEROTURNORDER[x].Health<=0)
							{
								HEROTURNORDER.Remove(HEROTURNORDER[x]);
							}
						}
					}

					if(P1_Turn)
					{
						EditorGUILayout.LabelField(HEROTURNORDER[HEROTURNORDER.Count-HEROTURNORDER.Count].NAMA+"'s turn Player 1",EditorStyles.toolbarButton);
						EditorGUILayout.BeginToggleGroup("Available Skills",P1_Turn);
						EditorGUILayout.LabelField("TARGET");
						if(TargetChosen==false&&!ENDTURN)
						{
							for(int j=0;j<temp2.Count;j++)
							{
								if(temp2[j].Health>0)
								{
									if(GUILayout.Button(temp2[j].NAMA)&&TargetChosen==false)
									{
										target=j;
										TargetChosen=true;
									}
								}
							}
						}
						EditorGUILayout.BeginHorizontal();
						if(TargetChosen)
						{
							if(GUILayout.Button("SKILL 1 - ATTACK"))
							{
								int damagedeal=Random.Range(0,temp.Find(p=>p.Equals(HEROTURNORDER[0])).Attack);
								HEROTURNORDER[0].Skill1(temp.Find(p => p.Equals(HEROTURNORDER[0])),temp2[target],damagedeal);
								ChangeLog.Add(temp.Find(p => p.Equals(HEROTURNORDER[0])).NAMA+" Doing Attack to "+temp2[target].NAMA+" with Damage Power "+damagedeal);
								TargetChosen=false;
								ENDTURN=true;
							}
							EditorGUILayout.BeginVertical();
							if(EditorGUILayout.BeginToggleGroup("",temp.Find(p=>p.Equals(HEROTURNORDER[0])).Mana>(HEROTURNORDER[0].MP*20/100)))
							{
								if(GUILayout.Button("SKILL 2 - SPECIAL ATTACK (20% MP)" ))
								{
									int damagedeal=Random.Range(0,temp.Find(p=>p.Equals(HEROTURNORDER[0])).Attack);
									HEROTURNORDER[0].Skill2(temp.Find(p => p.Equals(HEROTURNORDER[0])),temp2[target],damagedeal);
									ChangeLog.Add(temp.Find(p => p.Equals(HEROTURNORDER[0])).NAMA+" Doing Special Attack to "+temp2[target].NAMA+" with Damage Power "+damagedeal);
									USINGSKILL(temp.Find(p=>p.Equals(HEROTURNORDER[0])),20);
									TargetChosen=false;
									ENDTURN=true;
								}
							}
							EditorGUILayout.EndToggleGroup();
							if(EditorGUILayout.BeginToggleGroup("",temp.Find(p=>p.Equals(HEROTURNORDER[0])).Mana>(HEROTURNORDER[0].MP*30/100)))
							{
								if(GUILayout.Button("SKILL ULTIMATE (30% MP)"))
								{
									int damagedeal=Random.Range(0,temp.Find(p=>p.Equals(HEROTURNORDER[0])).Attack);
									HEROTURNORDER[0].Skill4(temp.Find(p => p.Equals(HEROTURNORDER[0])),temp2[target],damagedeal);
									ChangeLog.Add(temp.Find(p => p.Equals(HEROTURNORDER[0])).NAMA+" Doing Ultimate Attack to "+temp2[target].NAMA+" with Damage Power "+damagedeal);
									USINGSKILL(temp.Find(p=>p.Equals(HEROTURNORDER[0])),30);
									TargetChosen=false;
									ENDTURN=true;
								}
							}
							EditorGUILayout.EndToggleGroup();
							EditorGUILayout.EndVertical();
						}
						else if(!ENDTURN)
						{
							if(GUILayout.Button("SKILL 3 - DEFEND"))
							{
								HEROTURNORDER[0].Skill3(temp.Find(p => p.Equals(HEROTURNORDER[0])));
								ChangeLog.Add(temp.Find(p=>p.Equals(HEROTURNORDER[0])).NAMA+" Doing Defend (DEF INCREASED TO)" +temp.Find(p=>p.Equals(HEROTURNORDER[0])).DEF);
								TargetChosen=false;
								ENDTURN=true;
							}
						}
						if(GUILayout.Button("END TURN"))
						{
							if(HEROTURNORDER.Count>0)
							{
								HEROTURNORDER.RemoveAt(0);
								ENDTURN=false;
							}
						}
						EditorGUILayout.EndHorizontal();
						EditorGUILayout.EndToggleGroup();
					}
					
					if(P2_Turn)
					{
						EditorGUILayout.LabelField(HEROTURNORDER[HEROTURNORDER.Count-HEROTURNORDER.Count].NAMA+"'s turn Player 2",EditorStyles.toolbarButton);
						EditorGUILayout.BeginToggleGroup("Available Skills",P2_Turn);
						EditorGUILayout.LabelField("TARGET");
						if(TargetChosen==false&&!ENDTURN)
						{
						for(int j=0;j<temp.Count;j++)
						{
							if(temp[j].Health>0)
							{
								if(GUILayout.Button(temp[j].NAMA)&&TargetChosen==false)
								{
									target=j;
									TargetChosen=true;
								}
							}
						}
						}
						EditorGUILayout.BeginHorizontal();
						if(TargetChosen)
						{
							if(GUILayout.Button("SKILL 1 - ATTACK"))
							{
								int damagedeal=Random.Range(0,temp2.Find(p=>p.Equals(HEROTURNORDER[0])).Attack);
								HEROTURNORDER[0].Skill1(temp2.Find(p => p.Equals(HEROTURNORDER[0])),temp[target],damagedeal);
								ChangeLog.Add(temp2.Find(p => p.Equals(HEROTURNORDER[0])).NAMA+" Doing Attack to "+temp[target].NAMA+" with Damage Power "+damagedeal);
								TargetChosen=false;
								ENDTURN=true;
							}
							EditorGUILayout.BeginVertical();
							if(EditorGUILayout.BeginToggleGroup("",temp2.Find(p=>p.Equals(HEROTURNORDER[0])).Mana>(HEROTURNORDER[0].MP*20/100)))
							{
								if(GUILayout.Button("SKILL 2 - SPECIAL ATTACK (20% MP)" ))
								{
									int damagedeal=Random.Range(0,temp2.Find(p=>p.Equals(HEROTURNORDER[0])).Attack);
									HEROTURNORDER[0].Skill2(temp2.Find(p => p.Equals(HEROTURNORDER[0])),temp[target],damagedeal);
									ChangeLog.Add(temp2.Find(p => p.Equals(HEROTURNORDER[0])).NAMA+" Doing Special Attack to "+temp[target].NAMA+" with Damage Power "+damagedeal);
									USINGSKILL(temp2.Find(p=>p.Equals(HEROTURNORDER[0])),20);
									TargetChosen=false;
									ENDTURN=true;
								}
							}
							EditorGUILayout.EndToggleGroup();
							if(EditorGUILayout.BeginToggleGroup("",temp2.Find(p=>p.Equals(HEROTURNORDER[0])).Mana>(HEROTURNORDER[0].MP*30/100)))
							{
								if(GUILayout.Button("SKILL ULTIMATE (30% MP)"))
								{
									int damagedeal=Random.Range(0,temp2.Find(p=>p.Equals(HEROTURNORDER[0])).Attack);
									HEROTURNORDER[0].Skill4(temp2.Find(p => p.Equals(HEROTURNORDER[0])),temp[target],damagedeal);
									ChangeLog.Add(temp2.Find(p => p.Equals(HEROTURNORDER[0])).NAMA+" Doing Ultimate Attack to "+temp[target].NAMA+" with Damage Power "+damagedeal);
									USINGSKILL(temp2.Find(p=>p.Equals(HEROTURNORDER[0])),30);
									TargetChosen=false;
									ENDTURN=true;
								}
							}
							EditorGUILayout.EndToggleGroup();
							EditorGUILayout.EndVertical();

						}
						else if(!ENDTURN)
						{
							if(GUILayout.Button("SKILL 3 - DEFEND"))
							{
								HEROTURNORDER[0].Skill3(temp2.Find(p => p.Equals(HEROTURNORDER[0])));;
								ChangeLog.Add(temp2.Find(p=>p.Equals(HEROTURNORDER[0])).NAMA+" Doing Defend (DEF INCREASED TO)" +temp2.Find(p=>p.Equals(HEROTURNORDER[0])).DEF);
								TargetChosen=false;
								ENDTURN=true;
							}
						}
						if(GUILayout.Button("END TURN"))
						{
							if(HEROTURNORDER.Count>0)
							{
								HEROTURNORDER.RemoveAt(0);
								ENDTURN=false;
							}
						}
						EditorGUILayout.EndHorizontal();
						EditorGUILayout.EndToggleGroup();
					}

					if(P1_Turn||P2_Turn)
					{
						if(GUILayout.Button("OPEN COMBAT LOG"))
						{
							Open_Battle_ChangeLog();
						}
						EditorGUILayout.LabelField(" ",EditorStyles.boldLabel);
						EditorGUILayout.LabelField("--=============================================================--",EditorStyles.boldLabel);
						EditorGUILayout.LabelField(" ",EditorStyles.boldLabel);
						for(int f=0;f<temp.Count;f++)
						{
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("----------PLAYER 1----------",EditorStyles.boldLabel);
						EditorGUILayout.LabelField("||----------PLAYER 2----------",EditorStyles.boldLabel);
						EditorGUILayout.EndHorizontal();
						
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("ID :"+temp[f].ID,EditorStyles.boldLabel);
						EditorGUILayout.LabelField("||ID :"+temp2[f].ID,EditorStyles.boldLabel);
						EditorGUILayout.EndHorizontal();
						
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("NAMA :"+temp[f].NAMA,EditorStyles.boldLabel);
						EditorGUILayout.LabelField("||NAMA :"+temp2[f].NAMA,EditorStyles.boldLabel);
						EditorGUILayout.EndHorizontal();
						
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Tipe :"+temp[f].HeroTipe,EditorStyles.boldLabel);
						EditorGUILayout.LabelField("||Tipe :"+temp2[f].HeroTipe,EditorStyles.boldLabel);
						EditorGUILayout.EndHorizontal();
						
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("HP :",temp[f].Health.ToString());
						EditorGUILayout.LabelField("||HP :",temp2[f].Health.ToString());
						EditorGUILayout.EndHorizontal();
						
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("MP :",temp[f].Mana.ToString());
						EditorGUILayout.LabelField("||MP :",temp2[f].Mana.ToString());
						EditorGUILayout.EndHorizontal();
						
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("ATK :",temp[f].Attack.ToString());
						EditorGUILayout.LabelField("||ATK :",temp2[f].Attack.ToString());
						EditorGUILayout.EndHorizontal();
						
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("DEF :",temp[f].Defense.ToString());
						EditorGUILayout.LabelField("||DEF :",temp2[f].Defense.ToString());
						EditorGUILayout.EndHorizontal();
						
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("REC :",temp[f].Recovery.ToString());
						EditorGUILayout.LabelField("||REC :",temp2[f].Recovery.ToString());
						EditorGUILayout.EndHorizontal();
						
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("SPD :",temp[f].Speed.ToString());
						EditorGUILayout.LabelField("||SPD :",temp2[f].Speed.ToString());
						EditorGUILayout.EndHorizontal();
						}
					}



				}

				if(!Battle)
				{
					if(GUILayout.Button("BATTLE START"))
					{
						Battle=true;
					}

					/// show player status and parameters
					for(int f=0;f<parentEditor.TinkerPlayer_1.Count;f++)
					{
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("----------PLAYER 1----------",EditorStyles.boldLabel);
						EditorGUILayout.LabelField("||----------PLAYER 2----------",EditorStyles.boldLabel);
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("ID :"+parentEditor.TinkerPlayer_1[f].ID,EditorStyles.boldLabel);
						EditorGUILayout.LabelField("||ID :"+parentEditor.TinkerPlayer_2[f].ID,EditorStyles.boldLabel);
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("NAMA :"+parentEditor.TinkerPlayer_1[f].NAMA,EditorStyles.boldLabel);
						EditorGUILayout.LabelField("||NAMA :"+parentEditor.TinkerPlayer_2[f].NAMA,EditorStyles.boldLabel);
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Tipe :"+parentEditor.TinkerPlayer_1[f].HeroTipe,EditorStyles.boldLabel);
						EditorGUILayout.LabelField("||Tipe :"+parentEditor.TinkerPlayer_2[f].HeroTipe,EditorStyles.boldLabel);
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("HP :",parentEditor.TinkerPlayer_1[f].Health.ToString());
						EditorGUILayout.LabelField("||HP :",parentEditor.TinkerPlayer_2[f].Health.ToString());
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("MP :",parentEditor.TinkerPlayer_1[f].Mana.ToString());
						EditorGUILayout.LabelField("||MP :",parentEditor.TinkerPlayer_2[f].Mana.ToString());
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("ATK :",parentEditor.TinkerPlayer_1[f].Attack.ToString());
						EditorGUILayout.LabelField("||ATK :",parentEditor.TinkerPlayer_2[f].Attack.ToString());
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("DEF :",parentEditor.TinkerPlayer_1[f].Defense.ToString());
						EditorGUILayout.LabelField("||DEF :",parentEditor.TinkerPlayer_2[f].Defense.ToString());
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("REC :",parentEditor.TinkerPlayer_1[f].Recovery.ToString());
						EditorGUILayout.LabelField("||REC :",parentEditor.TinkerPlayer_2[f].Recovery.ToString());
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("SPD :",parentEditor.TinkerPlayer_1[f].Speed.ToString());
						EditorGUILayout.LabelField("||SPD :",parentEditor.TinkerPlayer_2[f].Speed.ToString());
						EditorGUILayout.EndHorizontal();
					}
				}
			}
			EditorGUILayout.EndScrollView();
		}
		else
		{
			Close();
		}
	}
コード例 #20
0
    public static void PreferencesGUI()
    {
        // Load the preferences
        if (!prefsLoaded)
        {
            LoadPrefs();
            prefsLoaded = true;
            OnWindowResize();
        }

        settingsScroll = EditorGUILayout.BeginScrollView(settingsScroll, GUILayout.MaxHeight(200));

        EditorGUI.BeginChangeCheck();

        /**
         * GENERAL SETTINGS
         */
        GUILayout.Label("General Settings", EditorStyles.boldLabel);

        pbStripProBuilderOnBuild   = EditorGUILayout.Toggle(new GUIContent("Strip PB Scripts on Build", "If true, when building an executable all ProBuilder scripts will be stripped from your built product."), pbStripProBuilderOnBuild);
        pbDisableAutoUV2Generation = EditorGUILayout.Toggle(new GUIContent("Disable Auto UV2 Generation", "Disables automatic generation of UV2 channel.  If Unity is sluggish when working with large ProBuilder objects, disabling UV2 generation will improve performance.  Use `Actions/Generate UV2` or `Actions/Generate Scene UV2` to build lightmap UVs prior to baking."), pbDisableAutoUV2Generation);
        pbShowSceneInfo            = EditorGUILayout.Toggle(new GUIContent("Show Scene Info", "Displays the selected object vertex and triangle counts in the scene view."), pbShowSceneInfo);
        pbShowEditorNotifications  = EditorGUILayout.Toggle("Show Editor Notifications", pbShowEditorNotifications);

        /**
         * TOOLBAR SETTINGS
         */
        GUILayout.Label("Toolbar Settings", EditorStyles.boldLabel);

        pbIconGUI           = EditorGUILayout.Toggle(new GUIContent("Use Icon GUI", "Toggles the ProBuilder window interface between text and icon versions."), pbIconGUI);
        pbShiftOnlyTooltips = EditorGUILayout.Toggle(new GUIContent("Shift Key Tooltips", "Tooltips will only show when the Shift key is held"), pbShiftOnlyTooltips);
        pbToolbarLocation   = (SceneToolbarLocation)EditorGUILayout.EnumPopup("Toolbar Location", pbToolbarLocation);

        pbUniqueModeShortcuts       = EditorGUILayout.Toggle(new GUIContent("Unique Mode Shortcuts", "When off, the G key toggles between Object and Element modes and H enumerates the element modes.  If on, G, H, J, and K are shortcuts to Object, Vertex, Edge, and Face modes respectively."), pbUniqueModeShortcuts);
        defaultOpenInDockableWindow = EditorGUILayout.Toggle("Open in Dockable Window", defaultOpenInDockableWindow);

        /**
         * DEFAULT SETTINGS
         */
        GUILayout.Label("Defaults", EditorStyles.boldLabel);

        pbDefaultMaterial = (Material)EditorGUILayout.ObjectField("Default Material", pbDefaultMaterial, typeof(Material), false);

        GUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Default Entity");
        pbDefaultEntity = ((EntityType)EditorGUILayout.EnumPopup((EntityType)pbDefaultEntity));
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Default Collider");
        defaultColliderType = ((ColliderType)EditorGUILayout.EnumPopup((ColliderType)defaultColliderType));
        GUILayout.EndHorizontal();

        if ((ColliderType)defaultColliderType == ColliderType.MeshCollider)
        {
            pbForceConvex = EditorGUILayout.Toggle("Force Convex Mesh Collider", pbForceConvex);
        }

                #if !UNITY_4_7
        GUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Shadow Casting Mode");
        pbShadowCastingMode = (ShadowCastingMode)EditorGUILayout.EnumPopup(pbShadowCastingMode);
        GUILayout.EndHorizontal();
                #endif

        /**
         * MISC. SETTINGS
         */
        GUILayout.Label("Misc. Settings", EditorStyles.boldLabel);

        pbDragCheckLimit   = EditorGUILayout.Toggle(new GUIContent("Limit Drag Check to Selection", "If true, when drag selecting faces, only currently selected pb-Objects will be tested for matching faces.  If false, all pb_Objects in the scene will be checked.  The latter may be slower in large scenes."), pbDragCheckLimit);
        pbPBOSelectionOnly = EditorGUILayout.Toggle(new GUIContent("Only PBO are Selectable", "If true, you will not be able to select non probuilder objects in Geometry and Texture mode"), pbPBOSelectionOnly);
        pbCloseShapeWindow = EditorGUILayout.Toggle(new GUIContent("Close shape window after building", "If true the shape window will close after hitting the build button"), pbCloseShapeWindow);
        pbDrawAxisLines    = EditorGUILayout.Toggle(new GUIContent("Dimension Overlay Lines", "When the Dimensions Overlay is on, this toggle shows or hides the axis lines."), pbDrawAxisLines);

        GUILayout.Space(4);

        /**
         * GEOMETRY EDITING SETTINGS
         */
        GUILayout.Label("Geometry Editing Settings", EditorStyles.boldLabel);

        pbElementSelectIsHamFisted   = !EditorGUILayout.Toggle(new GUIContent("Precise Element Selection", "When enabled you will be able to select object faces when in Vertex of Edge mode by clicking the center of a face.  When disabled, edge and vertex selection will always be restricted to the nearest element."), !pbElementSelectIsHamFisted);
        pbDragSelectWholeElement     = EditorGUILayout.Toggle("Precise Drag Select", pbDragSelectWholeElement);
        pbDefaultFaceColor           = EditorGUILayout.ColorField("Selected Face Color", pbDefaultFaceColor);
        pbDefaultEdgeColor           = EditorGUILayout.ColorField("Edge Wireframe Color", pbDefaultEdgeColor);
        pbDefaultVertexColor         = EditorGUILayout.ColorField("Vertex Color", pbDefaultVertexColor);
        pbDefaultSelectedVertexColor = EditorGUILayout.ColorField("Selected Vertex Color", pbDefaultSelectedVertexColor);
        pbVertexHandleSize           = EditorGUILayout.Slider("Vertex Handle Size", pbVertexHandleSize, 0f, 3f);
        pbForceVertexPivot           = EditorGUILayout.Toggle(new GUIContent("Force Pivot to Vertex Point", "If true, new objects will automatically have their pivot point set to a vertex instead of the center."), pbForceVertexPivot);
        pbForceGridPivot             = EditorGUILayout.Toggle(new GUIContent("Force Pivot to Grid", "If true, newly instantiated pb_Objects will be snapped to the nearest point on grid.  If ProGrids is present, the snap value will be used, otherwise decimals are simply rounded to whole numbers."), pbForceGridPivot);
        pbPerimeterEdgeBridgeOnly    = EditorGUILayout.Toggle(new GUIContent("Bridge Perimeter Edges Only", "If true, only edges on the perimeters of an object may be bridged.  If false, you may bridge any between any two edges you like."), pbPerimeterEdgeBridgeOnly);

        GUILayout.Space(4);

        GUILayout.Label("Experimental", EditorStyles.boldLabel);

        pbEnableExperimental = EditorGUILayout.Toggle(new GUIContent("Experimental Features", "Enables some experimental new features that we're trying out.  These may be incomplete or buggy, so please exercise caution when making use of this functionality!"), pbEnableExperimental);
        pbMeshesAreAssets    = EditorGUILayout.Toggle(new GUIContent("Meshes Are Assets", "Experimental!  Instead of storing mesh data in the scene, this toggle creates a Mesh cache in the Project that ProBuilder will use."), pbMeshesAreAssets);

        GUILayout.Space(4);

        /**
         * UV EDITOR SETTINGS
         */
        GUILayout.Label("UV Editing Settings", EditorStyles.boldLabel);
        pbUVGridSnapValue  = EditorGUILayout.FloatField("UV Snap Increment", pbUVGridSnapValue);
        pbUVGridSnapValue  = Mathf.Clamp(pbUVGridSnapValue, .015625f, 2f);
        pbUVEditorFloating = EditorGUILayout.Toggle(new GUIContent("Editor window floating", "If true UV   Editor window will open as a floating window"), pbUVEditorFloating);

        EditorGUILayout.EndScrollView();

        GUILayout.Space(4);

        GUILayout.Label("Shortcut Settings", EditorStyles.boldLabel);

        if (GUI.Button(resetRect, "Use defaults"))
        {
            ResetToDefaults();
        }

        ShortcutSelectPanel();
        ShortcutEditPanel();

        // Save the preferences
        if (EditorGUI.EndChangeCheck())
        {
            SetPrefs();
        }
    }
コード例 #21
0
        /// <summary>
        /// Update manifest file based on the settings.
        /// </summary>
        /// <param name="mode">Manifest modification mode being applied.</param>
        /// <param name="promptBeforeAction">Whether to display a window that prompts the user for
        /// confirmation before applying changes.</param>
        /// <param name="showDisableButton">Whether to show a button to disable auto-registry
        /// addition.</param>
        /// <param name="scopePrefixFilter">List of scope prefixes used to filter the set of registries
        /// being operated on.</param>
        internal static void UpdateManifest(ManifestModificationMode mode,
                                            bool promptBeforeAction = true,
                                            bool showDisableButton  = false,
                                            IEnumerable <string> scopePrefixFilter = null)
        {
            if (!ScopedRegistriesSupported)
            {
                logger.Log(String.Format("Scoped registries not supported in this version of Unity."),
                           level: LogLevel.Verbose);
                return;
            }

            PackageManifestModifier modifier = new PackageManifestModifier()
            {
                Logger = logger
            };
            Dictionary <string, List <PackageManagerRegistry> > manifestRegistries =
                modifier.ReadManifest() ? modifier.PackageManagerRegistries : null;

            if (manifestRegistries == null)
            {
                PackageManagerResolver.analytics.Report(
                    "registry_manifest/read/failed",
                    "Update Manifest failed: Read/Parse manifest failed");
                return;
            }

            var xmlRegistries = ReadRegistriesFromXml();

            // Filter registries using the scope prefixes.
            if (scopePrefixFilter != null)
            {
                foreach (var registry in new List <PackageManagerRegistry>(xmlRegistries.Values))
                {
                    bool removeRegistry = true;
                    foreach (var scope in registry.Scopes)
                    {
                        foreach (var scopePrefix in scopePrefixFilter)
                        {
                            if (scope.StartsWith(scopePrefix))
                            {
                                removeRegistry = false;
                            }
                        }
                    }
                    if (removeRegistry)
                    {
                        xmlRegistries.Remove(registry.Url);
                    }
                }
            }

            // Filter the set of considered registries based upon the modification mode.
            HashSet <string> selectedRegistryUrls = null;

            switch (mode)
            {
            case ManifestModificationMode.Add:
                // Remove all items from the XML loaded registries that are present in the manifest.
                foreach (var url in manifestRegistries.Keys)
                {
                    xmlRegistries.Remove(url);
                }
                selectedRegistryUrls = new HashSet <string>(xmlRegistries.Keys);
                break;

            case ManifestModificationMode.Remove:
                // Remove all items from the XML loaded registries that are not present in the
                // manifest.
                foreach (var url in new List <string>(xmlRegistries.Keys))
                {
                    if (!manifestRegistries.ContainsKey(url))
                    {
                        xmlRegistries.Remove(url);
                    }
                }
                selectedRegistryUrls = new HashSet <string>(xmlRegistries.Keys);
                break;

            case ManifestModificationMode.Modify:
                selectedRegistryUrls = new HashSet <string>();
                // Keep all XML loaded registries and select the items in the manifest.
                foreach (var url in xmlRegistries.Keys)
                {
                    if (manifestRegistries.ContainsKey(url))
                    {
                        selectedRegistryUrls.Add(url);
                    }
                }
                break;
            }

            // Applies the manifest modification based upon the modification mode.
            Action <HashSet <string> > syncRegistriesToManifest = (urlSelectionToApply) => {
                var addedRegistries = new List <PackageManagerRegistry>();
                SyncRegistriesToManifest(modifier, xmlRegistries, manifestRegistries,
                                         urlSelectionToApply,
                                         addRegistries: (mode == ManifestModificationMode.Add ||
                                                         mode == ManifestModificationMode.Modify),
                                         removeRegistries: (mode == ManifestModificationMode.Remove ||
                                                            mode == ManifestModificationMode.Modify),
                                         invertSelection: mode == ManifestModificationMode.Remove,
                                         addedRegistries: addedRegistries);
                // If any registries were added try migration if enabled.
                if (addedRegistries.Count > 0 && PromptToMigratePackages)
                {
                    PackageMigrator.MigratePackages();
                }
            };

            // Get the manifest json string based on the current selection and mode.
            Func <HashSet <string>, string> getManifestJsonAfterChange = (urlSelectionToApply) => {
                PackageManifestModifier       clonedModifier = new PackageManifestModifier(modifier);
                List <PackageManagerRegistry> toAdd;
                List <PackageManagerRegistry> toRemove;
                SyncRegistriesToModifier(clonedModifier, out toAdd, out toRemove,
                                         xmlRegistries, manifestRegistries,
                                         urlSelectionToApply,
                                         addRegistries: (mode == ManifestModificationMode.Add ||
                                                         mode == ManifestModificationMode.Modify),
                                         removeRegistries: (mode == ManifestModificationMode.Remove ||
                                                            mode == ManifestModificationMode.Modify),
                                         invertSelection: mode == ManifestModificationMode.Remove);
                return(clonedModifier.GetManifestJson());
            };

            if (xmlRegistries.Count > 0)
            {
                if (promptBeforeAction)
                {
                    // Build a list of items to display.
                    var registryItems = new List <KeyValuePair <string, string> >();
                    foreach (var kv in xmlRegistries)
                    {
                        registryItems.Add(new KeyValuePair <string, string>(kv.Key, kv.Value.Name));
                    }

                    // Optional when prompting is enabled or forced.
                    var window =
                        MultiSelectWindow.CreateMultiSelectWindow <PackageManagerResolverWindow>(
                            PLUGIN_NAME);
                    window.minSize        = new Vector2(1024, 500);
                    window.AvailableItems = registryItems;
                    window.Sort(1);
                    window.SelectedItems = selectedRegistryUrls;
                    switch (mode)
                    {
                    case ManifestModificationMode.Add:
                        window.Caption = String.Format("{0}\n\n{1}\n\n{2}",
                                                       ADD_REGISTRIES_QUESTION,
                                                       ADD_REGISTRIES_DESCRIPTION,
                                                       MODIFY_MENU_ITEM_DESCRIPTION);
                        window.ApplyLabel = "Add Selected Registries";
                        break;

                    case ManifestModificationMode.Remove:
                        window.Caption = String.Format("{0}\n\n{1}{2}",
                                                       REMOVE_REGISTRIES_QUESTION,
                                                       REMOVE_REGISTRIES_DESCRIPTION,
                                                       MODIFY_MENU_ITEM_DESCRIPTION);
                        window.ApplyLabel = "Remove Selected Registries";
                        break;

                    case ManifestModificationMode.Modify:
                        window.Caption = String.Format("{0}\n\n{1} {2}",
                                                       ADD_OR_REMOVE_REGISTRIES_QUESTION,
                                                       ADD_REGISTRIES_DESCRIPTION,
                                                       REMOVE_REGISTRIES_DESCRIPTION);
                        window.ApplyLabel = "Modify Registries";
                        break;
                    }
                    window.RenderItem = (item) => {
                        var registry       = xmlRegistries[item.Key];
                        var termsOfService = registry.TermsOfService;
                        if (!String.IsNullOrEmpty(termsOfService))
                        {
                            if (GUILayout.Button("View Terms of Service"))
                            {
                                Application.OpenURL(termsOfService);
                            }
                        }
                        var privacyPolicy = registry.PrivacyPolicy;
                        if (!String.IsNullOrEmpty(privacyPolicy))
                        {
                            if (GUILayout.Button("View Privacy Policy"))
                            {
                                Application.OpenURL(privacyPolicy);
                            }
                        }
                    };
                    // Set the scroll position to the bottom since "scopedRegistry" section is most
                    // likely at the bottom of the file.
                    scrollManifestViewLeft  = new Vector2(0.0f, float.PositiveInfinity);
                    scrollManifestViewRight = new Vector2(0.0f, float.PositiveInfinity);

                    // Render the change in manifest.json dynamically.
                    window.RenderAfterItems = () => {
                        GUILayout.Label("Changes to Packages/manifest.json");
                        EditorGUILayout.Space();

                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.BeginVertical();
                        GUILayout.Label("Before", EditorStyles.boldLabel);
                        EditorGUILayout.Space();
                        scrollManifestViewLeft =
                            EditorGUILayout.BeginScrollView(scrollManifestViewLeft,
                                                            GUILayout.MaxWidth(window.position.width / 2.0f));
                        EditorGUILayout.TextArea(modifier.GetManifestJson());
                        EditorGUILayout.EndScrollView();
                        EditorGUILayout.EndVertical();

                        EditorGUILayout.Space();

                        EditorGUILayout.BeginVertical();
                        GUILayout.Label("After", EditorStyles.boldLabel);
                        EditorGUILayout.Space();
                        scrollManifestViewRight =
                            EditorGUILayout.BeginScrollView(scrollManifestViewRight,
                                                            GUILayout.MaxWidth(window.position.width / 2.0f));
                        EditorGUILayout.TextArea(getManifestJsonAfterChange(window.SelectedItems));
                        EditorGUILayout.EndScrollView();
                        EditorGUILayout.EndVertical();

                        EditorGUILayout.EndHorizontal();
                    };
                    if (showDisableButton)
                    {
                        window.RenderBeforeCancelApply = () => {
                            if (GUILayout.Button("Disable Registry Addition"))
                            {
                                Enable = false;
                                window.Close();
                            }
                        };
                    }
                    window.OnApply = () => { syncRegistriesToManifest(window.SelectedItems); };
                    window.Show();
                }
                else
                {
                    syncRegistriesToManifest(selectedRegistryUrls);
                }
            }
        }
コード例 #22
0
        private void DoUpgradeGuidePage()
        {
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

            ShowBackupHelpBox();

            GUILayout.Label("Version 1.8+", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox(
                "FSMs saved with 1.8+ cannot be opened in earlier versions of PlayMaker! Please BACKUP projects!",
                MessageType.Warning);

            GUILayout.Label("Version 1.8.6", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox(
                "\nPlayMaker 1.8.6 is more strict about changes allowed in Prefab Instances: " +
                "If a Prefab Instance is modified in a way that is incompatible with the Prefab Parent it will be disconnected. " +
                "You can reconnect Instances using Apply or Revert." +
                "\n",
                MessageType.Warning);

            GUILayout.Label("Version 1.8.5", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox(
                "\nPlayMaker 1.8.5 moved LateUpdate handling to an optional component automatically added as needed.\n" +
                "\nIf you have custom actions that use LateUpdate you must add this to OnPreprocess:\n" +
                "\nFsm.HandleLateUpdate = true;\n" +
                "\nSee Rotate.cs for an example." +
                "\n",
                MessageType.Warning);

            GUILayout.Label("Version 1.8.2", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("\nPlayMaker 1.8.2 added the following system events:\n" +
                                    "\nMOUSE UP AS BUTTON, JOINT BREAK, JOINT BREAK 2D, PARTICLE COLLISION." +
                                    "\n\nPlease remove any custom proxy components you used before to send these events." +
                                    "\n",
                                    MessageType.Warning);

            GUILayout.Label("Version 1.8.1", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("\nPlayMaker 1.8.1 integrated the following add-ons and actions:\n" +
                                    "\n- Physics2D Add-on" +
                                    "\n- Mecanim Animator Add-on" +
                                    "\n- Vector2, Quaternion, and Trigonometry actions" +
                                    "\n\nThe new versions of these files are under \"Assets/PlayMaker/Actions\"" +
                                    "\n\nIf you imported these add-ons, the old versions are likely under \"Assets/PlayMaker Custom Actions\". " +
                                    "If you get errors from duplicate files after updating please delete the old files!" +
                                    "\n",
                                    MessageType.Warning);

            GUILayout.Label("Unity 5 Upgrade Notes", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox(
                "\nIf you run into problems updating a Unity 4.x project please check the Troubleshooting guide on the PlayMaker Wiki." +
                "\n",
                MessageType.Warning);
            EditorGUILayout.HelpBox("\nUnity 5 removed component property shortcuts from GameObject. " +
                                    "\n\nThe Unity auto update process replaces these properties with GetComponent calls. " +
                                    "In many cases this is fine, but some third party actions and addons might need manual updating! " +
                                    "Please post on the PlayMaker forums and contact the original authors for help." +
                                    "\n\nIf you used these GameObject properties in Get Property or Set Property actions " +
                                    "they are no longer valid, and you need to instead point to the Component directly. " +
                                    "E.g., Drag the Component (NOT the GameObject) into the Target Object field." +
                                    "\n", MessageType.Warning);

            GUILayout.Label("Unity 4.6 Upgrade Notes", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("\nFind support for the new Unity GUI online in our Addons page.\n", MessageType.Info);
            EditorGUILayout.HelpBox("\nPlayMakerGUI is only needed if you use OnGUI Actions. " +
                                    "If you don't use OnGUI actions un-check Auto-Add PlayMakerGUI in PlayMaker Preferences.\n", MessageType.Info);

            EditorGUILayout.EndScrollView();
            //FsmEditorGUILayout.Divider();
        }
コード例 #23
0
        void OnGUI()
        {
            EditorGUILayout.LabelField("Packages in this project", EditorStyles.whiteLargeLabel);

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            useGroupVersion = EditorGUILayout.ToggleLeft("Use common version for all packages in this project", useGroupVersion);

            if (EditorGUI.EndChangeCheck())
            {
                if (!useGroupVersion)
                {
                    PackageGroupConfiguration.UnsetGroupVersion();
                }
            }


            if (useGroupVersion)
            {
                EditorGUILayout.BeginHorizontal();
                groupVersion = EditorGUILayout.TextField("Group version: ", groupVersion);
                if (GUILayout.Button("Apply"))
                {
                    ApplyGroupVersion();
                }
                EditorGUILayout.EndHorizontal();
            }


            EditorGUILayout.Space();

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);


            foreach (PackageManifest package in packages)
            {
                GUIStyle boxStyle = new GUIStyle();
                boxStyle.padding = new RectOffset(10, 10, 0, 0);

                EditorGUILayout.BeginHorizontal(boxStyle);
                EditorGUILayout.LabelField(package.displayName);
                if (GUILayout.Button("Edit"))
                {
                    EditPackage(package);
                }
                if (GUILayout.Button("Add sample"))
                {
                    AddSample(package);
                }
                if (GUILayout.Button("Pack"))
                {
                    Pack(package);
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndScrollView();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Publish"))
            {
                PublishPackages();
            }

            if (GUILayout.Button("New package"))
            {
                NewPackage();
            }

            if (GUILayout.Button("Close"))
            {
                CloseWindow();
            }
            EditorGUILayout.EndHorizontal();
        }
コード例 #24
0
        void OnGUI()
        {
            if (invisibleButtonStyle == null)
            {
                invisibleButtonStyle = new GUIStyle("Button");

                invisibleButtonStyle.normal.background  = null;
                invisibleButtonStyle.focused.background = null;
                invisibleButtonStyle.hover.background   = null;
                invisibleButtonStyle.active.background  = null;
            }
            if (boxStyle == null)
            {
                boxStyle = new GUIStyle("Box");

                boxStyle.normal.textColor  = invisibleButtonStyle.normal.textColor;
                boxStyle.focused.textColor = invisibleButtonStyle.focused.textColor;
                boxStyle.hover.textColor   = invisibleButtonStyle.hover.textColor;
                boxStyle.active.textColor  = invisibleButtonStyle.active.textColor;
            }

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            foreach (var extensionGroup in extensions)
            {
                GUILayout.BeginVertical(extensionGroup.Key, boxStyle);

                GUILayout.Space(15);

                foreach (var extension in extensionGroup.Value)
                {
                    GUILayout.BeginHorizontal();
                    extension.isViewed = EditorGUILayout.Foldout(extension.isViewed, extension.AssetName, extension.Featured ? featuredFoldoutStyle : "Foldout");

                    if (extension.Featured)
                    {
                        GUILayout.Label(featuredIcon, GUILayout.Width(20), GUILayout.Height(20));
                    }

                    GUILayout.EndHorizontal();

                    if (extension.isViewed)
                    {
                        GUILayout.BeginHorizontal();

                        GUILayout.Space(15);

                        GUILayout.BeginVertical();

                        if (!extension.IsDefault)
                        {
                            extension.isActivated = EditorGUILayout.Toggle("Activated :", extension.isActivated);
                        }

                        GUILayout.Space(10);

                        GUILayout.BeginHorizontal();

                        Texture logo = UNExtension.GetLogo(extension);

                        if (logo != null)
                        {
                            GUILayout.Label(logo, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false));
                        }
                        EditorGUILayout.LabelField(extension.AssetDescription, GUILayout.Height(logo == null ? 50 : logo.height)); // draw description

                        GUILayout.EndHorizontal();

                        if (extension.isActivated && extension.HelperMethods.Count > 0)
                        {
                            GUILayout.Space(15);

                            GUILayout.BeginVertical("Tools : ", boxStyle);

                            GUILayout.Space(25);

                            for (int i = 0; i < extension.HelperMethods.Count; i++)
                            {
                                GUILayout.Space(2);

                                if (GUILayout.Button(extension.HelperMethods[i].Name))
                                {
                                    extension.HelperMethods[i].Invoke(extension, null);
                                }
                            }

                            GUILayout.EndVertical();
                        }

                        GUILayout.Space(15);

                        GUILayout.BeginHorizontal();

                        if (GUILayout.Button("Open Documentation", boxStyle))
                        {
                            UNExtension.OpenDocs(extension);
                        }
                        if (GUILayout.Button("Asset Store", boxStyle))
                        {
                            UNExtension.OpenAssetStore(extension);
                        }

                        GUILayout.EndHorizontal();

                        GUILayout.EndVertical();

                        GUILayout.EndHorizontal();
                    }

                    GUILayout.Space(5);
                }

                GUILayout.EndVertical();

                GUILayout.Space(5);
            }

            EditorGUILayout.EndScrollView();
        }
コード例 #25
0
        private void OnGUI()
        {
            EditorGUILayout.BeginHorizontal();
            showDependencies = EditorGUILayout.ToggleLeft("Show Relevance", showDependencies);
            if (GUILayout.Button("Unload All AB"))
            {
                AssetBundle.UnloadAllAssetBundles(false);
                LoadAssetBoundles();
            }
            EditorGUILayout.EndHorizontal();
            if (enties == null || enties.Count == 0)
            {
                EditorGUILayout.LabelField("Select a AssetBoundle File", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                return;
            }
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            foreach (Entiy entiy in enties)
            {
                EditorGUILayout.BeginHorizontal(GUI.skin.button);
                EditorGUILayout.LabelField(entiy.ab.name);
                if (entiy.abDepends != null && entiy.abDepends.Length > 0)
                {
                    EditorGUILayout.LabelField("Dependency: " + string.Join(",", entiy.abDepends));
                }
                EditorGUILayout.EndHorizontal();

                GUI.color = Color.white;
                if (entiy.assets != null)
                {
                    foreach (Object asset in entiy.assets)
                    {
                        //EditorGUILayout.Foldout(true,EditorGUIUtility.ObjectContent(asset, typeof(Object)));
                        EditorGUILayout.ObjectField(asset, typeof(Object), false);
                        DragLastUI(asset);
                        if (showDependencies)
                        {
                            Object[] dependencies = EditorUtility.CollectDependencies(new Object[] { asset }).OrderBy(x => x.GetType().Name).ThenBy(x => x.name).ToArray();
                            EditorGUI.indentLevel++;
                            foreach (Object obj in dependencies)
                            {
                                if (obj != asset)
                                {
                                    EditorGUILayout.ObjectField(obj, typeof(Object), true);
                                    DragLastUI(obj);
                                }
                            }
                            EditorGUI.indentLevel--;
                        }
                    }
                }
                if (!showDependencies)
                {
                    GUI.color = new Color(0.7f, 0.7f, 0.7f, 1f);
                    if (entiy.depends != null)
                    {
                        foreach (Object asset in entiy.depends)
                        {
                            EditorGUILayout.ObjectField(asset, typeof(Object), false);
                            DragLastUI(asset);
                        }
                    }
                    GUI.color = Color.white;
                }
            }

            EditorGUILayout.EndScrollView();
        }
コード例 #26
0
                private void RenderTable()
                {
                    _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, false, false);
                    {
                        float          defaultItemHeight = GetItemHeight();
                        SystemLanguage currentLanguage   = Localisation.GetCurrentLanguage();
                        float          secondLangWidth   = position.width - _editorPrefs._keyWidth - _editorPrefs._firstLanguageWidth;

                        //On layout, check what part of table is currently being viewed
                        if (Event.current.type == EventType.Layout || _keysDirty)
                        {
                            GetViewableRange(_scrollPosition.y, GetTableAreaHeight(), defaultItemHeight, out _viewStartIndex, out _viewEndIndex, out _contentStart, out _contentHeight);
                        }

                        EditorGUILayout.BeginVertical(GUILayout.Height(_contentHeight));
                        {
                            //Blank space until start of content
                            GUILayout.Label(GUIContent.none, GUILayout.Height(_contentStart));

                            //Then render viewable range
                            for (int i = _viewStartIndex; i < _viewEndIndex; i++)
                            {
                                bool selected = IsSelected(_keys[i]);

                                Color origBackgroundColor = GUI.backgroundColor;
                                Color origContentColor    = GUI.contentColor;

                                //Work out item height
                                float itemHeight;
                                {
                                    if (selected)
                                    {
                                        //Work out highest text size
                                        string textA       = Localisation.GetRawString(_keys[i], Localisation.GetCurrentLanguage());
                                        float  textAHeight = _selectedTextStyle.CalcHeight(new GUIContent(textA), _editorPrefs._firstLanguageWidth);

                                        string textB       = Localisation.GetRawString(_keys[i], _editorPrefs._secondLanguage);
                                        float  textBHeight = _selectedTextStyle.CalcHeight(new GUIContent(textB), secondLangWidth);

                                        float textHeight = Mathf.Max(textAHeight, textBHeight);

                                        itemHeight = Mathf.Max(defaultItemHeight, textHeight);
                                    }
                                    else
                                    {
                                        itemHeight = defaultItemHeight;
                                    }
                                }

                                //Render item
                                GUI.backgroundColor = selected ? kSelectedTextLineBackgroundColor : i % 2 == 0 ? kTextLineBackgroundColorA : kTextLineBackgroundColorB;
                                EditorGUILayout.BeginHorizontal(_tableStyle, GUILayout.Height(itemHeight));
                                {
                                    GUI.backgroundColor = origBackgroundColor;
                                    GUI.contentColor    = selected ? kSelectedTextColor : Color.white;

                                    //Render Key
                                    EditorGUILayout.BeginVertical();
                                    {
                                        if (_editingKeyName == _keys[i])
                                        {
                                            EditorGUI.BeginChangeCheck();
                                            string key = EditorGUILayout.DelayedTextField(_keys[i], _editKeyStyle, GUILayout.Width(_editorPrefs._keyWidth), GUILayout.Height(itemHeight));
                                            if (EditorGUI.EndChangeCheck())
                                            {
                                                _editingKeyName = null;
                                                Localisation.ChangeKey(_keys[i], key);
                                                UpdateKeys();
                                            }
                                        }
                                        else
                                        {
                                            if (GUILayout.Button(_keys[i], selected ? _selectedKeyStyle : _keyStyle, GUILayout.Width(_editorPrefs._keyWidth), GUILayout.Height(itemHeight)))
                                            {
                                                OnClickItem(i, SystemLanguage.Unknown);
                                            }
                                        }
                                    }
                                    EditorGUILayout.EndVertical();

                                    //Render Text
                                    {
                                        GUI.backgroundColor = i % 2 == 0 ? kTextBackgroundColorA : kTextBackgroundColorB;

                                        //Render First Language
                                        string text = Localisation.GetRawString(_keys[i], currentLanguage);

                                        if (GUILayout.Button(selected ? text : StringUtils.GetFirstLine(text), selected ? _selectedTextStyle : _textStyle, GUILayout.Width(_editorPrefs._firstLanguageWidth), GUILayout.Height(itemHeight)))
                                        {
                                            OnClickItem(i, currentLanguage);
                                        }

                                        //Render Second Language
                                        EditorGUILayout.BeginVertical(GUILayout.Width(secondLangWidth));
                                        {
                                            string stext = Localisation.GetRawString(_keys[i], _editorPrefs._secondLanguage);

                                            if (GUILayout.Button(selected ? stext : StringUtils.GetFirstLine(stext), selected ? _selectedTextStyle : _textStyle, GUILayout.Width(secondLangWidth), GUILayout.Height(itemHeight)))
                                            {
                                                OnClickItem(i, _editorPrefs._secondLanguage);
                                            }
                                        }
                                        EditorGUILayout.EndVertical();
                                    }
                                }
                                EditorGUILayout.EndHorizontal();

                                GUI.backgroundColor = origBackgroundColor;
                                GUI.contentColor    = origContentColor;
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndScrollView();
                }
コード例 #27
0
        private static void OnGUI()
        {
            if (OSXEditor)
            {
                EditorGUILayout.HelpBox("Due to OS X system limitations, the plugin will only be fullscreen if the main window is maximized and the dock is set to auto-hide, and it'll still show a thin bar at the bottom.", MessageType.Warning);
            }
            else if (LinuxEditor)
            {
                EditorGUILayout.HelpBox("This plugin was not tested on Linux and its behaviour is unknown.", MessageType.Warning);
            }

            EditorGUILayout.Separator();

            scroll.Value = EditorGUILayout.BeginScrollView(scroll);

            EditorGUILayout.HelpBox("Enabling the option below will prevent the default game view from rendering and may improve the plugin performance", MessageType.Warning);
            GameViewInputFix.DoGUI();
            EditorGUILayout.Separator();
            ToolbarVisible.DoGUI();
            FullscreenOnPlayEnabled.DoGUI();

            EditorGUI.indentLevel++;
            using (new EditorGUI.DisabledGroupScope(!FullscreenOnPlayEnabled))
                FullscreenOnPlayGiveWay.DoGUI();
            EditorGUI.indentLevel--;

            EditorGUILayout.Separator();
            MutipleWindowMode.DoGUI();

            if (WindowsEditor || LinuxEditor || !IsRectModeSupported(RectSource))
            {
                RectSource.DoGUI();
            }

            DisableNotifications.DoGUI();

            if (!IsRectModeSupported(RectSource))
            {
                EditorGUILayout.HelpBox("The selected Rect Source mode is not supported on this platform", MessageType.Warning);
            }

            switch (RectSource.Value)
            {
            case RectSourceMode.CustomRect:
                EditorGUI.indentLevel++;
                CustomRect.DoGUI();

                var customRect = CustomRect.Value;

                if (customRect.width < 300f)
                {
                    customRect.width = 300f;
                }
                if (customRect.height < 300f)
                {
                    customRect.height = 300f;
                }

                CustomRect.Value = customRect;

                EditorGUI.indentLevel--;
                break;
            }

            EditorGUILayout.Separator();
            Shortcut.DoShortcutsGUI();
            EditorGUILayout.Separator();
            EditorGUILayout.HelpBox("Each item has a tooltip explaining its behaviour", MessageType.Info);
            EditorGUILayout.EndScrollView();

            using (new EditorGUILayout.HorizontalScope()) {
                if (GUILayout.Button(resetSettingsContent, GUILayout.Width(120f)))
                {
                    DeleteSavedValues();
                }

                if (GUILayout.Button(mailDeveloperContent, GUILayout.Width(120f)))
                {
                    Application.OpenURL(GetEmailURL());
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.LabelField(versionContent, GUILayout.Width(45f));
            }

            EditorGUILayout.Separator();
        }
コード例 #28
0
    private void OnGUI()
    {
        GUI.skin.window.margin = new RectOffset(20, 20, 10, 10);

        EditorGUILayout.BeginVertical();
        pos = EditorGUILayout.BeginScrollView(pos);

        maxSize = new Vector2(_width, _height);
        minSize = maxSize / 2;

        GUILayout.Space(20);

        GUI.DrawTexture(GUILayoutUtility.GetRect(150, 150), (Texture)Resources.Load("Textures/Editor/logo"), ScaleMode.ScaleToFit);

        GUILayout.Space(20);

        EditorGUILayout.LabelField("Ayuda", _title);
        EditorGUI.DrawRect(GUILayoutUtility.GetRect(100, 2), Color.black);

        GUILayout.Space(20);

        EditorGUILayout.LabelField("Introducción:", _subtitle);
        GUILayout.Space(5);
        GUILayout.Label("«Paradox Engine» es una herramienta para Unity con la cual se pueden crear, principalmente, juegos del genero Novela visual. Sin embargo, debido a la versatilidad de «Paradox Engine» puede usarse como sistema de diálogos e incluso manejar eventos serializados.", _text);

        GUILayout.Space(20);

        EditorGUILayout.LabelField("Database", _subtitle);
        GUILayout.Space(5);
        GUILayout.Label("En la base de datos se pueden definir los personajes, escenarios y sonidos a utilizar, así como también modificar algunas configuraciones.", _text);
        GUILayout.Label("Abrir ventana: Paradox Engine -> Database.", _text);

        GUILayout.Space(20);

        EditorGUILayout.LabelField("FlowChart", _subtitle);
        GUILayout.Space(5);
        GUILayout.Label("El mapa de flujo es creado y editado mediante un editor de nodos. Cada nodo cuenta con sus propios atributos editables intuitivamente desde el inspector.", _text);
        GUILayout.Label("Abrir ventana: Paradox Engine -> FlowChart -> Launch Graph.", _text);

        GUILayout.Space(20);

        EditorGUILayout.LabelField("GraphPlayer", _subtitle);
        GUILayout.Space(5);
        GUILayout.Label("El GraphPlayer es un componente el cual se encarga de ejecutar los FlowCharts en la escena. Es recomendable utilizar el prefab completamente configurado para cargar el mapa de flujo y utilizar.", _text);
        GUILayout.Label("Abrir ventana: Paradox Engine -> Scene Container -> Create", _text);

        GUILayout.Space(20);

        EditorGUILayout.LabelField("Ventana de FlowChart", _subtitle);
        GUILayout.Space(5);
        GUILayout.Label("File", _points);
        GUILayout.Label(" Permite crear y borrar FlowCart, así como cargar los datos de uno o quitar el que esté cargado.", _text);

        GUILayout.Space(5);

        GUILayout.Label("Insert", _points);
        GUILayout.Label(" Permite crear todos los tipos de nodos disponibles dentro del FlowChart.", _text);

        GUILayout.Space(5);

        GUILayout.Label("Tools", _points);
        GUILayout.Label(" Cuando abrimos la ventana del FlowChart siempre cargará el último grapho cargado al cerrar, aquí se encuentra la opción que permite borrar el mencionado cache.", _text);

        GUILayout.Space(5);

        GUILayout.Label("Add Parameter", _points);
        GUILayout.Label(" En la subventana de parámetros se pueden agregar variables globales para el juego.", _text);

        GUILayout.Space(5);

        GUILayout.Label("Controles", _points);
        GUILayout.Label(" Clic izquierdo: Seleccionar nodos. Si se mantiene se pueden arrastrar.", _text);
        GUILayout.Label(" Clic derecho: Abre menú contextual. Si se preciona sobre un nodo te permite desconectar sus conecciones o borrar el nodo. Si se preciona sobre cualquier parte sobre la grilla ofrece las mismas opciones de «File» y «Insert» juntos, en el caso de que se tenga para conectar el nodo y creas otro mediante este menú contextual se conectarán automáticamente.", _text);
        GUILayout.Label(" Clic central: Si se mantiene puede realizarse paneos en el FlowChart.", _text);
        GUILayout.Label(" Rueda del mouse: Permite realizar zoom in y zoom out en el FlowChart.", _text);
        GUILayout.Label(" Flechas de desplazamiento laterales: Permiten agrandar y achicar la subventana de parámetros.", _text);

        GUILayout.Space(20);

        GUILayout.Label("Nodos", _subtitle);
        GUILayout.Label("Cada nodo en particular, a pesar de sus nombres descriptivos, tiene en el inspector una breve explicación de qué funcionalidad realizan.", _text);

        GUILayout.Space(20);

        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
コード例 #29
0
    void DrawFields()
    {
        defaultColor       = GUI.backgroundColor;
        scrollViewPosition = EditorGUILayout.BeginScrollView(scrollViewPosition, EditorStyles.textField);

        GUI.backgroundColor = Color.black;
        EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.ExpandHeight(true));
        GUI.backgroundColor = defaultColor;

        // Fields header
        EditorGUILayout.BeginHorizontal(fieldTextStyle);

        fieldTextStyle.fontStyle        = FontStyle.Bold;
        fieldTextStyle.normal.textColor = Color.white;
        fieldTextStyle.alignment        = TextAnchor.MiddleLeft;
        GUILayout.Space(20);
        EditorGUILayout.LabelField("Title", fieldTextStyle, GUILayout.Width(titleWidth));
        EditorGUILayout.LabelField("Value", fieldTextStyle, GUILayout.MinWidth(100), GUILayout.ExpandWidth(true));
        EditorGUILayout.LabelField("Category", fieldTextStyle, GUILayout.Width(categoryWidth));

        EditorGUILayout.EndHorizontal();
        GUILayout.Space(2);

        // Minimal width
        tWidth = 70;
        fWidth = 100;
        cWidth = 100;

        // Fields

        keys = new List <string> (categories.Keys);
        keys.Sort(delegate(string x, string y) {
            if (x == "Warning")
            {
                return(1);
            }
            if (y == "Warning")
            {
                return(-1);
            }
            if (x == "Error")
            {
                return(1);
            }
            if (y == "Error")
            {
                return(-1);
            }
            if (x == "System")
            {
                return(1);
            }
            if (y == "System")
            {
                return(-1);
            }
            return(x.CompareTo(y));
        });
        DrawFieldsOfCategory("");
        foreach (string key in keys)
        {
            if (ignoreDeflog && DebugPanel.IsDeflog(key))
            {
                continue;
            }
            if (key == "")
            {
                continue;
            }
            DrawFieldHeader(key);
            if (!categories[key])
            {
                continue;
            }
            DrawFieldsOfCategory(key);
        }
        EditorGUILayout.EndVertical();

        // Calculating widthes
        titleWidth    += (tWidth - titleWidth) * 0.8f;
        fieldWidth    += (fWidth - fieldWidth) * 0.8f;
        categoryWidth += (cWidth - categoryWidth) * 0.8f;

        GUI.backgroundColor = defaultColor;
        EditorGUILayout.EndScrollView();
    }
コード例 #30
0
        private void OnGUI()
        {
            if (!PrepareSettings())
            {
                return;
            }

            if (!CurrentSettings)
            {
                GUIHelper.DisplayObjectOption("Grabbit Settings", ref CurrentSettings);
                return;
            }


            if (ToolManager.activeToolType != typeof(GrabbitTool))
            {
                InactiveGrabbitGUI();
                return;
            }

            HeaderGUI();

            var previous = CurrentSettings.CurrentMode;

            CurrentSettings.CurrentMode = (GrabbitMode)GUILayout.Toolbar((int)CurrentSettings.CurrentMode,
                                                                         Enum.GetNames(typeof(GrabbitMode)));

            var modif = false;

            if (previous != CurrentSettings.CurrentMode)
            {
                CheckPauseMode();
            }

            if (previous != CurrentSettings.CurrentMode)
            {
                CurrentTool.CanUndo = true;
            }

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            EditorGUILayout.BeginVertical(CurrentSettings.TabStyle);

            switch (CurrentSettings.CurrentMode)
            {
            case GrabbitMode.PLACE:
                modif = DisplayPlacementParams();
                break;

            case GrabbitMode.ROTATE:
                modif = DisplayRotateParams();
                break;

            case GrabbitMode.ALIGN:
                modif = DisplayAlignParams();
                break;

            case GrabbitMode.FALL:
                modif = DisplayGravityParams();
                break;

            case GrabbitMode.POINT:
                modif = DisplayPointParams();
                break;

            case GrabbitMode.SETTINGS:
                modif = DisplayPreferenceParams();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndScrollView();

            if (modif || prefChanged)
            {
                EditorUtility.SetDirty(CurrentSettings);
                SceneView.lastActiveSceneView.Focus();
                if (CurrentSettings.CurrentMode == GrabbitMode.SETTINGS)
                {
                    prefChanged = true;
                    GUIHelper.DisplayMessage("<b>Please restart Grabbit for the changes to take effect</b>");
                }
            }

            if (!CurrentSettings.HideGrabbitTextLogo)
            {
                GUILayout.Label(CurrentSettings.GrabbitTextLogo, new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.MiddleRight, fixedHeight = Mathf.Min(position.height * 0.06f, 25)
                });
            }
        }