Beispiel #1
0
        static void OnGUI(UnityModManager.ModEntry modEntry)
        {
            GUILayout.Label(title, GUILayout.Width(300));
            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle(Main.settings.useWarehouse == 0, "新版仓库"))
            {
                Warehouse_UpdateActorItems_Patch.SetNewWarehouse(true);
                Main.settings.useWarehouse = 0;
            }
            if (GUILayout.Toggle(Main.settings.useWarehouse == 1, "旧版仓库"))
            {
                Main.settings.useWarehouse = 1;
            }
            if (GUILayout.Toggle(Main.settings.useWarehouse == 2, "原版仓库"))
            {
                Warehouse_UpdateActorItems_Patch.SetNewWarehouse(false);
                Main.settings.useWarehouse = 2;
            }
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            string sNum = GUILayout.TextField(Main.settings.numberOfColumns.ToString());
            int    num;

            if (int.TryParse(sNum, out num))
            {
                if (num > 0 || num < 1000)
                {
                    Main.settings.numberOfColumns = num;
                }
            }
            GUILayout.Label(string.Format("←←←←←← 设置背包一行显示{0}个物品:   <color=#F63333>修改行数和仓库版本设置建议重启游戏!</color>", Main.settings.numberOfColumns));
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("<color=#F63333>取消拖拽存取物品功能    按住Ctrl+点击物品存取全部物品</color>");
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            string content = GUILayout.TextField(Main.settings.tackNum.ToString());
            int    takeNum;

            if (int.TryParse(content, out takeNum))
            {
                if (takeNum > 0 || takeNum < 1000)
                {
                    Main.settings.tackNum = takeNum;
                }
            }
            GUILayout.Label(string.Format("<color=#F63333>←←←←←← 设置按住Shift+点击物品存储{0}个物品</color>", Main.settings.tackNum));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            string speed = GUILayout.TextField(Main.settings.scrollSpeed.ToString());
            int    s;

            if (int.TryParse(speed, out s))
            {
                if (s > 0 || s < 1000)
                {
                    Main.settings.scrollSpeed = s;
                }
            }
            GUILayout.Label(string.Format("←←←←←← 设置背包滚轮滑动速度{0}", Main.settings.scrollSpeed));
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            Main.settings.useClassify = GUILayout.HorizontalSlider(Main.settings.useClassify, 0, 1) <= 0.5f ? 0 : 1;
            GUILayout.Label(string.Format("开启分类搜索:<color=#F63333>({0})</color>", Main.settings.useClassify == 0 ? "关" : "开"));
            if (Main.settings.useClassify == 1)
            {
                Main.settings.levelClassify = Main.MaxLevelClassify(); //等级筛选
                Main.settings.bookClassify  = Main.MaxBookClassify();  //书籍筛选
                                                                       //Main.settings.attrClassify = Main.MaxAttrClassify();//属性
            }
            GUILayout.EndHorizontal();
            //GUILayout.BeginHorizontal();
            //GUILayout.Label("默认打开仓库标签:");
            //if (warehouse != null)
            //{
            //    for (int i = 0; i < warehouse.titleName.Length; i++)
            //    {
            //        if (GUILayout.Toggle(Main.settings.openTitle == i, warehouse.titleName[i]))
            //        {
            //            Main.settings.openTitle = i;
            //        }
            //    }
            //}
            //GUILayout.EndHorizontal();
        }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        Map m = (Map)target;

        showDimensions = EditorGUILayout.Foldout(showDimensions, "Map Dimensions");
        if (showDimensions)
        {
            //		EditorGUI.indentLevel++;
            GUILayout.BeginHorizontal();
            GUILayout.Label("Width", GUILayout.Width(78));
            float nextXSz = EditorGUILayout.FloatField(m.size.x, GUILayout.Width(32));
            GUILayout.Label("Height", GUILayout.Width(78));
            float   nextYSz = EditorGUILayout.FloatField(m.size.y, GUILayout.Width(32));
            Vector2 nextSz  = new Vector2(nextXSz, nextYSz);
            if (nextSz != m.size)
            {
                RegisterUndo("Map Size Change");
                m.size = nextSz;
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Side Length", GUILayout.Width(78));
            float nextLength = EditorGUILayout.FloatField(m.sideLength, GUILayout.Width(32));
            if (nextLength != m.sideLength)
            {
                RegisterUndo("Map Side Length Change");
                m.sideLength = nextLength;
            }
            GUILayout.Label("Tile Height", GUILayout.Width(78));
            float nextHeight = EditorGUILayout.FloatField(m.tileHeight, GUILayout.Width(32));
            if (nextHeight != m.tileHeight)
            {
                RegisterUndo("Map Side Height Change");
                m.tileHeight = nextHeight;
            }
            GUILayout.EndHorizontal();
            //		EditorGUI.indentLevel--;
        }

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Edit Z", GUILayout.Width(78));
        int nextZ = EditorGUILayout.IntSlider(editZ, 0, 20);

        if (nextZ != editZ)
        {
//			RegisterUndo(target, "Map Height Selection");
            editZ = nextZ;
        }
        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        EditorGUILayout.BeginHorizontal();
        GUIContent[] toolbarOptions = new GUIContent[3];
        toolbarOptions[(int)EditMode.AddRemove] = new GUIContent("Add/Remove");
        toolbarOptions[(int)EditMode.Reshape]   = new GUIContent("Reshape");
        toolbarOptions[(int)EditMode.Paint]     = new GUIContent("Paint");
        EditMode nextMode = (EditMode)GUILayout.Toolbar((int)editMode, toolbarOptions);

        EditorGUILayout.EndHorizontal();
        if (nextMode != editMode)
        {
            editMode        = nextMode;
            editModeChanged = true;
        }
        if (editMode == EditMode.AddRemove || editMode == EditMode.Reshape)
        {
            //show inset/offset settings for current stamp
            GUILayout.BeginHorizontal();
            GUILayout.Label("Invisible", GUILayout.Width(78));
            makeInvisibleTiles = EditorGUILayout.Toggle(makeInvisibleTiles);
            GUILayout.EndHorizontal();
            GUILayout.Label("Side Insets");
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("-X", GUILayout.Width(32));
            sideInsets[(int)Neighbors.FrontLeftIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.FrontLeftIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.BackRightIdx]);
            GUILayout.Label("+X", GUILayout.Width(32));
            sideInsets[(int)Neighbors.BackRightIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.BackRightIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.FrontLeftIdx]);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("-Y", GUILayout.Width(32));
            sideInsets[(int)Neighbors.FrontRightIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.FrontRightIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.BackLeftIdx]);
            GUILayout.Label("+Y", GUILayout.Width(32));
            sideInsets[(int)Neighbors.BackLeftIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.BackLeftIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.FrontRightIdx]);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("-Z", GUILayout.Width(32));
            sideInsets[(int)Neighbors.BottomIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.BottomIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.TopIdx]);
            GUILayout.Label("+Z", GUILayout.Width(32));
            sideInsets[(int)Neighbors.TopIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.TopIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.BottomIdx]);
            EditorGUILayout.EndHorizontal();
            // GUILayout.Label("Corner Insets (not yet implemented)");
            // EditorGUILayout.BeginHorizontal();
            // GUILayout.Label(" 0", GUILayout.Width(32));
            // cornerInsets[(int)Corners.Front] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Front], GUILayout.Width(32)), 0, 1.0f);
            // GUILayout.Label("+X", GUILayout.Width(32));
            // cornerInsets[(int)Corners.Right] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Right], GUILayout.Width(32)), 0, 1.0f);
            // EditorGUILayout.EndHorizontal();
            // EditorGUILayout.BeginHorizontal();
            // GUILayout.Label("+Y", GUILayout.Width(32));
            // cornerInsets[(int)Corners.Left ] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Left ], GUILayout.Width(32)), 0, 1.0f);
            // GUILayout.Label("+XY", GUILayout.Width(32));
            // cornerInsets[(int)Corners.Back ] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Back ], GUILayout.Width(32)), 0, 1.0f);
            // EditorGUILayout.EndHorizontal();
        }
        else if (editMode == EditMode.Paint)
        {
            EditorGUILayout.Separator();
            specScrollPos = EditorGUILayout.BeginScrollView(specScrollPos, true, false, GUILayout.Height(80));
            EditorGUILayout.BeginHorizontal(GUILayout.Height(64));
            //show list of texture specs controls
            //a texture spec is a rectangular Texture2D with some metadata
            //only for now, there's no metadata.
            //this metadata gets stored in the map object, which composes the
            //textures into an atlas. uvs are mapped from this atlas.
            //changes to the texture spec list force recreation of the mesh.
            //texture spec info for each face is stored as part of the MapTile class.
            Texture2D[] textures = new Texture2D[m.TileSpecCount + 1];
            if (specPlaceholderTexture == null)
            {
                specPlaceholderTexture = EditorGUIUtility.LoadRequired("SpecPlaceholder.png") as Texture2D;
            }
            for (int i = 0; i < m.TileSpecCount; i++)
            {
                Texture2D specTex = m.TileSpecAt(i).texture;
                if (specTex != null)
                {
                    textures[i] = specTex;
                }
                else
                {
                    textures[i] = specPlaceholderTexture;
                }
            }
            textures[m.TileSpecCount] = specPlaceholderTexture;
            var names = new Dictionary <string, int>();
            for (int i = 0; i < textures.Length; i++)
            {
                Texture2D tex = textures[i];
                GUIUpdateTexture(tex, i, names);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndScrollView();
            string n = GUI.GetNameOfFocusedControl();
            if (names.ContainsKey(n))
            {
                if (names[n] < m.TileSpecCount)
                {
                    specSelectedSpec = names[n];
                }
            }
            EditorGUI.indentLevel++;
            //now, show the parameters for this spec
            bool oldEnabled = GUI.enabled;
            GUI.enabled = specSelectedSpec < m.TileSpecCount;

            if (GUILayout.Button("Delete Tile"))
            {
                RegisterUndo("Delete Tile Spec");
                m.RemoveTileSpecAt(specSelectedSpec);
                while (specSelectedSpec >= m.TileSpecCount)
                {
                    specSelectedSpec--;
                    if (specSelectedSpec < 0)
                    {
                        specSelectedSpec = 0; break;
                    }
                }
            }
            GUI.enabled = oldEnabled;
            EditorGUI.indentLevel--;
            EditorGUILayout.Separator();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Beispiel #3
0
        private void OnGUI()
        {
            string selectedPath = AssetDatabase.GetAssetPath(UnityEditor.Selection.activeObject);

            if (string.IsNullOrEmpty(selectedPath))
            {
                return;
            }

            // Standard spacing to mimic Unity's Inspector header
            GUILayout.Space(2);

            Rect rect;

            GUILayout.BeginHorizontal("In BigTitle");
            GUILayout.Label(AssetDatabase.GetCachedIcon(selectedPath), GUILayout.Width(36), GUILayout.Height(36));
            GUILayout.BeginVertical();
            GUILayout.Label(Path.GetFileName(selectedPath), TitleStyle);
            // Display directory (without "Assets/" prefix)
            GUILayout.Label(Regex.Match(Path.GetDirectoryName(selectedPath), "(\\\\.*)$").Value);
            rect = GUILayoutUtility.GetLastRect();
            GUILayout.EndVertical();
            GUILayout.Space(44);
            GUILayout.EndHorizontal();

            if (Directory.Exists(selectedPath))
            {
                return;
            }

            AssetInfo selectedAssetInfo = ProjectCurator.GetAsset(selectedPath);

            if (selectedAssetInfo == null)
            {
                bool rebuildClicked = HelpBoxWithButton(new GUIContent("You must rebuild database to obtain information on this asset", EditorGUIUtility.IconContent("console.warnicon").image), new GUIContent("Rebuild Database"));
                if (rebuildClicked)
                {
                    ProjectCurator.RebuildDatabase();
                }
                return;
            }

            var content = new GUIContent(selectedAssetInfo.IsIncludedInBuild ? ProjectIcons.LinkBlue : ProjectIcons.LinkBlack, selectedAssetInfo.IncludedStatus.ToString());

            GUI.Label(new Rect(position.width - 20, rect.y + 1, 16, 16), content);

            scroll = GUILayout.BeginScrollView(scroll);

            dependenciesOpen = EditorGUILayout.Foldout(dependenciesOpen, $"Dependencies ({selectedAssetInfo.dependencies.Count})");
            if (dependenciesOpen)
            {
                foreach (var dependency in selectedAssetInfo.dependencies)
                {
                    if (GUILayout.Button(Path.GetFileName(dependency), ItemStyle))
                    {
                        UnityEditor.Selection.activeObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(dependency);
                    }
                    rect = GUILayoutUtility.GetLastRect();
                    GUI.DrawTexture(new Rect(rect.x - 16, rect.y, rect.height, rect.height), AssetDatabase.GetCachedIcon(dependency));
                    AssetInfo depInfo = ProjectCurator.GetAsset(dependency);
                    content = new GUIContent(depInfo.IsIncludedInBuild ? ProjectIcons.LinkBlue : ProjectIcons.LinkBlack, depInfo.IncludedStatus.ToString());
                    GUI.Label(new Rect(rect.width + rect.x - 20, rect.y + 1, 16, 16), content);
                }
            }

            GUILayout.Space(6);

            referencesOpen = EditorGUILayout.Foldout(referencesOpen, $"Referencers ({selectedAssetInfo.referencers.Count})");
            if (referencesOpen)
            {
                foreach (var referencer in selectedAssetInfo.referencers)
                {
                    if (GUILayout.Button(Path.GetFileName(referencer), ItemStyle))
                    {
                        UnityEditor.Selection.activeObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(referencer);
                    }
                    rect = GUILayoutUtility.GetLastRect();
                    GUI.DrawTexture(new Rect(rect.x - 16, rect.y, rect.height, rect.height), AssetDatabase.GetCachedIcon(referencer));
                    AssetInfo refInfo = ProjectCurator.GetAsset(referencer);
                    content = new GUIContent(refInfo.IsIncludedInBuild ? ProjectIcons.LinkBlue : ProjectIcons.LinkBlack, refInfo.IncludedStatus.ToString());
                    GUI.Label(new Rect(rect.width + rect.x - 20, rect.y + 1, 16, 16), content);
                }
            }

            GUILayout.Space(5);

            GUILayout.EndScrollView();

            if (!selectedAssetInfo.IsIncludedInBuild)
            {
                bool deleteClicked = HelpBoxWithButton(new GUIContent("This asset is not referenced and never used. Would you like to delete it ?", EditorGUIUtility.IconContent("console.warnicon").image), new GUIContent("Delete Asset"));
                if (deleteClicked)
                {
                    File.Delete(selectedPath);
                    AssetDatabase.Refresh();
                    ProjectCurator.RemoveAssetFromDatabase(selectedPath);
                }
            }
        }
Beispiel #4
0
    //----------------------------------------------------------------------------
    protected override void OnInternalInspectorGUI()
    {
        MapDatabase.MapItem item = MapDatabase.GetMaByUniqueId(m_currentlySelected);

        if (item != null)
        {
            GUILayout.BeginVertical();
            {
                EditorGUILayout.LabelField("Map unique ID", item.m_uniqueId.ToString());
                item.m_levelIndex = EditorGUILayout.IntField("Map level index", item.m_levelIndex);

                item.m_name = EditorGUILayout.TextField("Map Name", item.m_name);

                item.m_mapPrefab = EditorGUILayout.ObjectField("Map prefab", item.m_mapPrefab, typeof(GameObject), false) as GameObject;

                // Attack list
                GUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Encounterable wild Pokemons");
                    if (GUILayout.Button(m_listUnfolded ? "Hide" : "Show"))
                    {
                        m_listUnfolded = !m_listUnfolded;
                    }
                }
                GUILayout.EndHorizontal();

                if (m_listUnfolded)
                {
                    foreach (MapDatabase.MapWildPokemon element in item.m_wildPokemonList)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField(" ", GUILayout.MaxWidth(40));
                            element.m_pokemonId = EditorGUILayout.Popup(element.m_pokemonId, m_pokemonNames);
                            EditorGUILayout.LabelField(" ", GUILayout.Width(20));
                            element.m_minLvl = EditorGUILayout.IntField("Level min", element.m_minLvl);
                            EditorGUILayout.LabelField(" ", GUILayout.Width(20));
                            element.m_maxLvl = EditorGUILayout.IntField("Level max", element.m_maxLvl);
                            EditorGUILayout.LabelField(" ", GUILayout.Width(20));
                            element.m_proba = EditorGUILayout.IntField("Encounter Proba", element.m_proba);
                            EditorGUILayout.LabelField(" ", GUILayout.Width(20));

                            if (GUILayout.Button("-"))
                            {
                                m_delete          = true;
                                m_elementToDelete = new KeyValuePair <int, MapDatabase.MapWildPokemon> (item.m_uniqueId, element);
                            }
                        }
                        GUILayout.EndHorizontal();
                    }

                    GUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.LabelField(" ", GUILayout.MaxWidth(40));
                        if (GUILayout.Button("+"))
                        {
                            AddNewWildPokemon(item.m_uniqueId);
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndVertical();
        }

        // Delay deletion so we don't do it during the for each loop
        if (m_delete)
        {
            RemoveWildPokemon(m_elementToDelete.Key, m_elementToDelete.Value);
            m_delete = false;
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
 public override void OnInspectorGUI()
 {
     GUILayout.BeginHorizontal();
     EditorGUILayout.TextArea(serializedObject.targetObject.ToString());
     GUILayout.EndHorizontal();
 }
        private void RenderList(SerializedProperty list)
        {
            // Disable speech commands if we could not initialize successfully
            using (new GUIEnabledWrapper(isInitialized, false))
            {
                EditorGUILayout.Space();
                GUILayout.BeginVertical();

                if (MixedRealityEditorUtility.RenderIndentedButton(AddButtonContent, EditorStyles.miniButton))
                {
                    list.arraySize += 1;
                    var speechCommand   = list.GetArrayElementAtIndex(list.arraySize - 1);
                    var localizationKey = speechCommand.FindPropertyRelative("localizationKey");
                    localizationKey.stringValue = string.Empty;
                    var keyword = speechCommand.FindPropertyRelative("keyword");
                    keyword.stringValue = string.Empty;
                    var keyCode = speechCommand.FindPropertyRelative("keyCode");
                    keyCode.intValue = (int)KeyCode.None;
                    var action   = speechCommand.FindPropertyRelative("action");
                    var actionId = action.FindPropertyRelative("id");
                    actionId.intValue = 0;
                }

                GUILayout.Space(12f);

                if (list == null || list.arraySize == 0)
                {
                    EditorGUILayout.HelpBox("Create a new Speech Command.", MessageType.Warning);
                    GUILayout.EndVertical();
                    return;
                }

                GUILayout.BeginVertical();

                GUILayout.BeginHorizontal();
                var labelWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 36f;
                EditorGUILayout.LabelField(LocalizationContent, GUILayout.ExpandWidth(true));
                EditorGUILayout.LabelField(KeywordContent, GUILayout.ExpandWidth(true));
                EditorGUILayout.LabelField(KeyCodeContent, GUILayout.Width(64f));
                EditorGUILayout.LabelField(ActionContent, GUILayout.Width(64f));
                EditorGUILayout.LabelField(string.Empty, GUILayout.Width(24f));
                EditorGUIUtility.labelWidth = labelWidth;
                GUILayout.EndHorizontal();

                for (int i = 0; i < list.arraySize; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    SerializedProperty speechCommand = list.GetArrayElementAtIndex(i);
                    var localizationKey = speechCommand.FindPropertyRelative("localizationKey");
                    EditorGUILayout.PropertyField(localizationKey, GUIContent.none, GUILayout.ExpandWidth(true));

                    var keyword = speechCommand.FindPropertyRelative("keyword");
                    EditorGUILayout.PropertyField(keyword, GUIContent.none, GUILayout.ExpandWidth(true));

                    var keyCode = speechCommand.FindPropertyRelative("keyCode");
                    EditorGUILayout.PropertyField(keyCode, GUIContent.none, GUILayout.Width(64f));

                    var action            = speechCommand.FindPropertyRelative("action");
                    var actionId          = action.FindPropertyRelative("id");
                    var actionDescription = action.FindPropertyRelative("description");
                    var actionConstraint  = action.FindPropertyRelative("axisConstraint");

                    EditorGUI.BeginChangeCheck();
                    actionId.intValue = EditorGUILayout.IntPopup(GUIContent.none, actionId.intValue, actionLabels, actionIds, GUILayout.Width(64f));

                    if (EditorGUI.EndChangeCheck())
                    {
                        MixedRealityInputAction inputAction = actionId.intValue == 0 ? MixedRealityInputAction.None : MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions[actionId.intValue - 1];
                        actionDescription.stringValue   = inputAction.Description;
                        actionConstraint.enumValueIndex = (int)inputAction.AxisConstraint;
                    }

                    if (GUILayout.Button(MinusButtonContent, EditorStyles.miniButtonRight, GUILayout.Width(24f)))
                    {
                        list.DeleteArrayElementAtIndex(i);
                    }

                    EditorGUILayout.EndHorizontal();
                }

                GUILayout.EndVertical();
                GUILayout.EndVertical();
            }
        }
 protected override void OnGUI()
 {
     base.OnGUI();
     GUI.enabled = !Application.isPlaying;
     GUILayout.BeginHorizontal();
     EditorGUI.BeginChangeCheck();
     editMode = GUILayout.Toggle(editMode, "Edit", EditorStyles.toolbarButton);
     if (EditorGUI.EndChangeCheck())
     {
         OnEditModeUpdate();
     }
     if (GUILayout.Button("Revert", EditorStyles.toolbarButton))
     {
         navMeshTri.triangulation = NavMeshTriangulationObject.Empty;
         editMode = false;
         OnEditModeUpdate();
     }
     GUILayout.EndHorizontal();
     GUI.enabled = true;
     GUILayout.BeginHorizontal();
     GUI.color = Color.yellow;
     if (GUILayout.Button("Export", EditorStyles.toolbarButton))
     {
         string path = EditorUtility.SaveFilePanel("选择保存路径", "", "NetMesh.data", "data");
         try
         {
             BinaryWriter         writer   = new BinaryWriter(new FileStream(path, FileMode.Create), System.Text.Encoding.UTF8);
             NavMeshTriangulation t        = NavMesh.CalculateTriangulation();
             List <Vector3>       vertices = null;
             List <int>           indices  = null;
             List <int>           layers   = null;
             NavMeshUtil.FilterDuplicate(t, out vertices, out indices, out layers);
             Debug.Log("顶点数量: " + vertices.Count);
             writer.Write(vertices.Count);
             vertices.ToList <Vector3>().ForEach((Vector3 each) =>
             {
                 writer.Write(each.x);
                 writer.Write(each.y);
                 writer.Write(each.z);
             });
             writer.Write(layers.Count);
             Debug.Log("三角形数量: " + layers.Count);
             indices.ToList <int>().ForEach((int each) =>
             {
                 writer.Write(each);
             });
             layers.ToList <int>().ForEach((int each) =>
             {
                 writer.Write(each);
             });
             writer.Flush();
             writer.Close();
         }
         catch (Exception e)
         {
             Debug.LogError(e.Message + "\n" + e.StackTrace);
         }
     }
     GUI.color = Color.white;
     GUILayout.EndHorizontal();
 }
    public override void OnInspectorGUI()
    {
        ServerSettings settings = (ServerSettings)this.target;

        #if UNITY_3_5
        EditorGUIUtility.LookLikeInspector();
        #endif


        settings.HostType     = (ServerSettings.HostingOption)EditorGUILayout.EnumPopup("Hosting", settings.HostType);
        EditorGUI.indentLevel = 1;

        switch (settings.HostType)
        {
        case ServerSettings.HostingOption.BestRegion:
        case ServerSettings.HostingOption.PhotonCloud:
            if (settings.HostType == ServerSettings.HostingOption.PhotonCloud)
            {
                settings.PreferredRegion = (CloudRegionCode)EditorGUILayout.EnumPopup("Region", settings.PreferredRegion);
            }
            settings.AppID    = EditorGUILayout.TextField("AppId", settings.AppID);
            settings.Protocol = (ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol", settings.Protocol);

            if (string.IsNullOrEmpty(settings.AppID) || settings.AppID.Equals("master"))
            {
                EditorGUILayout.HelpBox("The Photon Cloud needs an AppId (GUID) set.\nYou can find it online in your Dashboard.", MessageType.Warning);
            }
            break;

        case ServerSettings.HostingOption.SelfHosted:
            if (settings.Protocol == ConnectionProtocol.Udp && settings.ServerPort == 4530)
            {
                settings.ServerPort = 5055;
            }
            else if (settings.Protocol == ConnectionProtocol.Tcp && settings.ServerPort == 5055)
            {
                settings.ServerPort = 4530;
            }
            settings.ServerAddress = EditorGUILayout.TextField("Server Address", settings.ServerAddress);
            settings.ServerAddress = settings.ServerAddress.Trim();
            settings.ServerPort    = EditorGUILayout.IntField("Server Port", settings.ServerPort);
            settings.Protocol      = (ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol", settings.Protocol);
            settings.AppID         = EditorGUILayout.TextField("AppId", settings.AppID);
            break;

        case ServerSettings.HostingOption.OfflineMode:
            EditorGUI.indentLevel = 0;
            EditorGUILayout.HelpBox("In 'Offline Mode', the client does not communicate with a server.\nAll settings are hidden currently.", MessageType.Info);
            break;

        case ServerSettings.HostingOption.NotSet:
            EditorGUI.indentLevel = 0;
            EditorGUILayout.HelpBox("Hosting is 'Not Set'.\nConnectUsingSettings() will not be able to connect.\nSelect another option or run the PUN Wizard.", MessageType.Info);
            break;

        default:
            DrawDefaultInspector();
            break;
        }

        if (PhotonEditor.CheckPunPlus())
        {
            settings.Protocol = ConnectionProtocol.Udp;
            EditorGUILayout.HelpBox("You seem to use PUN+.\nPUN+ only supports reliable UDP so the protocol is locked.", MessageType.Info);
        }

        settings.AppID = settings.AppID.Trim();

        EditorGUI.indentLevel = 0;
        SerializedObject   sObj  = new SerializedObject(this.target);
        SerializedProperty sRpcs = sObj.FindProperty("RpcList");
        EditorGUILayout.PropertyField(sRpcs, true);
        sObj.ApplyModifiedProperties();

        GUILayout.BeginHorizontal();
        GUILayout.Space(20);
        if (GUILayout.Button("Refresh RPCs"))
        {
            PhotonEditor.UpdateRpcList();
            Repaint();
        }
        if (GUILayout.Button("Clear RPCs"))
        {
            PhotonEditor.ClearRpcList();
        }
        if (GUILayout.Button("Log HashCode"))
        {
            Debug.Log("RPC-List HashCode: " + RpcListHashCode() + ". Make sure clients that send each other RPCs have the same RPC-List.");
        }
        GUILayout.Space(20);
        GUILayout.EndHorizontal();

        //SerializedProperty sp = serializedObject.FindProperty("RpcList");
        //EditorGUILayout.PropertyField(sp, true);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
        ///<summary>
        ///Drawing all the timers in the window
        ///</summary>
        private void WindowTimerText()
        {
            //Looping through the timers in the timermanager.
            //doing it in a for loop, because foreach gives an error that im editing the list.
            for (int i = 0; i < TimerManager.Instance.Timers.Count; i++)
            {
                Timer timer = TimerManager.Instance.Timers[i];

                float  time = timer.SettedTime;
                string temp = "";

                //Good English is the base of everything.
                temp = (time <= 1) ? "second" : "seconds";

                EditorGUILayout.LabelField("New Unity Timer");

                EditorGUILayout.LabelField(string.Format("Timer running for the next {0} {1}", time.ToString("#00.0"), temp));
                EditorGUILayout.LabelField(string.Format("Calling methode: {0:0}", timer.methodeInfo));
                //add stop pauze and play button
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(playButton, GUILayout.Width(Screen.width * 0.02f)))
                {
                    timer.PauseTimer = false;
                }
                if (GUILayout.Button(pauseButton, GUILayout.Width(Screen.width * 0.02f)))
                {
                    timer.PauseTimer = true;
                }
                //Screen.width multiply by a value whats the offset
                float heightOffset = Screen.height * 0.02801f;

                if (GUILayout.Button(stopButton, GUILayout.Width(Screen.width * 0.02f), GUILayout.Height(heightOffset)))
                {
                    timer.RemoveTimer();
                }
                GUILayout.EndHorizontal();
                EditorGUILayout.LabelField("--------------------------------");
            }
            #region Deprecated code
            //foreach (Timer timer in TimerManager.Instance.Timers)
            //{
            //    float time = timer.SettedTime;
            //    string temp = "";

            //    //good english is the base of everything.
            //    if (time <= 1)
            //        temp = "second";
            //    else
            //        temp = "seconds";

            //    EditorGUILayout.LabelField("New Unity Timer");
            //    EditorGUILayout.LabelField(string.Format("Timer running for the next {0} {1}", time.ToString("#00.0"), temp));
            //    EditorGUILayout.LabelField(string.Format("Calling methode: {0:0}", timer.methodeInfo));
            //    //add stop pauze and play button
            //    GUILayout.BeginHorizontal();
            //    if (GUILayout.Button(playButton, GUILayout.Width(Screen.width * 0.02f)))
            //        timer.PauseTimer = false;
            //    if (GUILayout.Button(pauseButton, GUILayout.Width(Screen.width * 0.02f)))
            //        timer.PauseTimer = true;
            //    //Screen.width multiply by a value whats the offset
            //    float heightOffset = Screen.height * 0.02801f;

            //    if (GUILayout.Button(stopButton, GUILayout.Width(Screen.width * 0.02f), GUILayout.Height(heightOffset)))
            //        timer.RemoveTimer();
            //    GUILayout.EndHorizontal();
            //    EditorGUILayout.LabelField("--------------------------------");
            //}
            #endregion
        }
Beispiel #10
0
    /// <summary>
    /// Draw the custom wizard.
    /// </summary>

    void OnGUI()
    {
        // Load the saved preferences
        if (!mLoaded)
        {
            mLoaded = true; Load();
        }

        EditorGUIUtility.fieldWidth = 0f;
        EditorGUIUtility.labelWidth = 80f;

        GameObject go = NGUIEditorTools.SelectedRoot();

        if (go == null)
        {
            GUILayout.Label("You must create a UI first.");

            if (GUILayout.Button("Open the New UI Wizard"))
            {
                EditorWindow.GetWindow <UICreateNewUIWizard>(false, "New UI", true);
            }
        }
        else
        {
            GUILayout.Space(4f);

            GUILayout.BeginHorizontal();
            ComponentSelector.Draw <UIAtlas>(NGUISettings.atlas, OnSelectAtlas, GUILayout.Width(140f));
            GUILayout.Label("Texture atlas used by widgets", GUILayout.MinWidth(10000f));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            ComponentSelector.Draw <UIFont>(NGUISettings.font, OnSelectFont, GUILayout.Width(140f));
            GUILayout.Label("Font used by labels", GUILayout.MinWidth(10000f));
            GUILayout.EndHorizontal();

            GUILayout.Space(-2f);
            NGUIEditorTools.DrawSeparator();

            GUILayout.BeginHorizontal();
            WidgetType wt = (WidgetType)EditorGUILayout.EnumPopup("Template", mType, GUILayout.Width(200f));
            GUILayout.Space(20f);
            GUILayout.Label("Select a widget template to use");
            GUILayout.EndHorizontal();

            if (mType != wt)
            {
                mType = wt; Save();
            }

            switch (mType)
            {
            case WidgetType.Label:                  CreateLabel(go); break;

            case WidgetType.Sprite:                 CreateSprite(go, mSprite); break;

            case WidgetType.Texture:                CreateSimpleTexture(go); break;

            case WidgetType.Button:                 CreateButton(go); break;

            case WidgetType.ImageButton:    CreateImageButton(go); break;

            case WidgetType.Checkbox:               CreateCheckbox(go); break;

            case WidgetType.ProgressBar:    CreateSlider(go, false); break;

            case WidgetType.Slider:                 CreateSlider(go, true); break;

            case WidgetType.Input:                  CreateInput(go); break;

            case WidgetType.PopupList:              CreatePopup(go, true); break;

            case WidgetType.PopupMenu:              CreatePopup(go, false); break;

            case WidgetType.ScrollBar:              CreateScrollBar(go); break;
            }
        }
    }
Beispiel #11
0
        internal void OnGUI()
        {
            if (IconSelector.m_Styles == null)
            {
                IconSelector.m_Styles = new IconSelector.Styles();
            }
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                this.CloseWindow();
            }
            Texture2D texture2D = EditorGUIUtility.GetIconForObject(this.m_TargetObject);
            bool      flag      = false;

            if (Event.current.type == EventType.Repaint)
            {
                texture2D = this.ConvertLargeIconToSmallIcon(texture2D, ref flag);
            }
            Event     current = Event.current;
            EventType type    = current.type;

            GUI.BeginGroup(new Rect(0f, 0f, base.position.width, base.position.height), IconSelector.m_Styles.background);
            this.DoTopSection(texture2D != null);
            GUILayout.Space(22f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(1f);
            GUI.enabled = false;
            GUILayout.Label(string.Empty, IconSelector.m_Styles.seperator, new GUILayoutOption[0]);
            GUI.enabled = true;
            GUILayout.Space(1f);
            GUILayout.EndHorizontal();
            GUILayout.Space(3f);
            if (this.m_ShowLabelIcons)
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(6f);
                for (int i = 0; i < this.m_LabelIcons.Length / 2; i++)
                {
                    this.DoButton(this.m_LabelIcons[i], texture2D, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(6f);
                for (int j = this.m_LabelIcons.Length / 2; j < this.m_LabelIcons.Length; j++)
                {
                    this.DoButton(this.m_LabelIcons[j], texture2D, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(1f);
                GUI.enabled = false;
                GUILayout.Label(string.Empty, IconSelector.m_Styles.seperator, new GUILayoutOption[0]);
                GUI.enabled = true;
                GUILayout.Space(1f);
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(9f);
            for (int k = 0; k < this.m_SmallIcons.Length / 2; k++)
            {
                this.DoButton(this.m_SmallIcons[k], texture2D, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(9f);
            for (int l = this.m_SmallIcons.Length / 2; l < this.m_SmallIcons.Length; l++)
            {
                this.DoButton(this.m_SmallIcons[l], texture2D, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
            bool flag2     = false;
            int  controlID = GUIUtility.GetControlID(IconSelector.s_HashIconSelector, FocusType.Keyboard);

            if (GUILayout.Button(EditorGUIUtility.TempContent("Other..."), new GUILayoutOption[0]))
            {
                GUIUtility.keyboardControl = controlID;
                flag2 = true;
            }
            GUI.backgroundColor = new Color(1f, 1f, 1f, 1f);
            GUI.EndGroup();
            if (flag2)
            {
                ObjectSelector.get.Show(this.m_TargetObject, typeof(Texture2D), null, false);
                ObjectSelector.get.objectSelectorID = controlID;
                GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
                current.Use();
                GUIUtility.ExitGUI();
            }
            EventType eventType = type;

            if (eventType == EventType.ExecuteCommand)
            {
                string commandName = current.commandName;
                if (commandName == "ObjectSelectorUpdated" && ObjectSelector.get.objectSelectorID == controlID && GUIUtility.keyboardControl == controlID)
                {
                    Texture2D icon = ObjectSelector.GetCurrentObject() as Texture2D;
                    EditorGUIUtility.SetIconForObject(this.m_TargetObject, icon);
                    GUI.changed = true;
                    current.Use();
                }
            }
        }
        public void DrawAxis(Rect windowRect)
        {
            if (!DeviceManager.SDL_Initialized)
            {
#if windows
                GUILayout.Label("<b>Additional library needed</b>\n" +
                                "Controller axis requires SDL2 library to work.\n" +
                                "Press download to install it automatically.\n\n"+
                                "<b>Platform</b>\n" +
                                "You are using Windows version of ACM.\n"+
                                "If you are using some other operating system,\n"+
                                "download the correct version of the mod.");
                if (GUILayout.Button(download_button_text) && !downloading_in_progress && !DeviceManager.SDL_Installed)
                    DeviceManager.InstallSDL();
#elif linux
                GUILayout.Label("<b>Additional library needed</b>\n" +
                                "Controller axis requires SDL2 library to work.\n" +
                                "Run the command below to install it.\n\n"+
                                "<b>Platform</b>\n" +
                                "You are using Linux version of ACM.\n" +
                                "If you are using some other operating system,\n" +
                                "download the correct version of the mod.");
                GUILayout.TextField("sudo apt-get install libsdl2-2.0-0");
#elif osx
                GUILayout.Label("<b>Additional library needed</b>\n" +
                                "Controller axis requires SDL2 library to work.\n" +
                                "Download it at the link below.\n\n"+
                                "<b>Platform</b>\n" +
                                "You are using OSX version of ACM.\n" +
                                "If you are using some other operating system,\n" +
                                "download the correct version of the mod.");
                if (GUILayout.Button("www.libsdl.org/download-2.0.php"))
                    Application.OpenURL("www.libsdl.org/download-2.0.php");
#endif
            }
            else if (Controller.NumDevices == 0)
            {
                note =  "<color=#FFFF00><b>No controllers connected.</b></color>\n"+
                        "Connect a joystick or controller to use this axis.";
            }
            else if (controller_index < 0)
            {
                note = "<color=#FFFF00><b>Associated controller not connected.</b></color>\n" +
                        "The device this axis is bound to is not found.\n"+
                        "\n<b>Device GUID</b>\n" + Axis.GUID;
                if (GUILayout.Button("Use another controller"))
                {
                    controller_index = 0;
                    Axis.GUID = Controller.DeviceList[controller_index];
                }
            }
            else
            {
                error = null;
                note = null;

                controller = Controller.Get(Axis.GUID);
                Axis.Axis %= controller.NumAxes;

                // Graph rect
                graphRect = new Rect(
                    GUI.skin.window.padding.left,
                    GUI.skin.window.padding.top + 36,
                    windowRect.width - GUI.skin.window.padding.left - GUI.skin.window.padding.right,
                    windowRect.width - GUI.skin.window.padding.left - GUI.skin.window.padding.right);

                // Axis value
                GUI.Label(new Rect(graphRect.x, graphRect.y, graphRect.width, 20),
                        "  <color=#808080><b>"+ Axis.OutputValue.ToString("0.00")+"</b></color>",
                        new GUIStyle(Elements.Labels.Default) { richText = true, alignment = TextAnchor.MiddleLeft });

                // Draw drag controls
                if (Axis.OffsetX == 0 && Axis.OffsetY == 0)
                {
                    GUI.Label(new Rect(graphRect.x, graphRect.y + graphRect.height - 20, graphRect.width, 20),
                        "<color=#808080><b>DRAG TO SET OFFSET</b></color>",
                        new GUIStyle(Elements.Labels.Default) { richText = true, alignment = TextAnchor.MiddleCenter });
                }
                else
                {
                    GUI.Label(new Rect(graphRect.x, graphRect.y + graphRect.height - 20, (graphRect.width - 16) / 2, 20),
                        "  <color=#808080><b>X: " + Axis.OffsetX.ToString("0.00") + "\tY:" + Axis.OffsetY.ToString("0.00") + "</b></color>",
                        new GUIStyle(Elements.Labels.Default) { richText = true, alignment = TextAnchor.MiddleLeft });
                    if (GUI.Button(new Rect(graphRect.x + (graphRect.width - 16) / 2, graphRect.y + graphRect.height - 20, (graphRect.width - 16) / 2, 20),
                            "<color=#808080><b>RESET OFFSET</b></color>",
                            new GUIStyle(Elements.Labels.Default) { richText = true, alignment = TextAnchor.MiddleRight }))
                    {
                        Axis.OffsetX = 0;
                        Axis.OffsetY = 0;
                    }
                }

                // Draw graph
                DrawGraph();

                // Listen for drag
                var mousePos = UnityEngine.Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                var drag_handle = new Rect(windowRect.x + graphRect.x, windowRect.y + graphRect.y, graphRect.width, graphRect.height);
                var drag_range = (graphRect.width) / 2f;

                if (!dragging && UnityEngine.Input.GetMouseButtonDown(0) && drag_handle.Contains(mousePos))
                {
                    dragging = true;
                    click_position = mousePos;
                    click_position.x += Axis.OffsetX * drag_range;
                    click_position.y += Axis.OffsetY * drag_range;
                }

                if (dragging)
                {
                    Axis.OffsetX = Mathf.Clamp((click_position.x - mousePos.x) / drag_range, -1f, 1f);
                    Axis.OffsetY = Mathf.Clamp((click_position.y - mousePos.y) / drag_range, -1f, 1f);
                    if (UnityEngine.Input.GetMouseButtonUp(0))
                    {
                        dragging = false;
                    }
                }

                // Draw graph input and frame
                Util.DrawRect(graphRect, Color.gray);
                Util.FillRect(new Rect(
                        graphRect.x + graphRect.width / 2,
                        graphRect.y,
                        1,
                        graphRect.height),
                    Color.gray);
                Util.FillRect(new Rect(
                        graphRect.x,
                        graphRect.y + graphRect.height / 2,
                        graphRect.width,
                        1),
                    Color.gray);

                Util.FillRect(new Rect(
                                  graphRect.x + graphRect.width / 2 + graphRect.width / 2 * Axis.InputValue,
                                  graphRect.y,
                                  1,
                                  graphRect.height),
                         Color.yellow);

                // Draw controller selection
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("<", controller_index > 0 ? Elements.Buttons.Default : Elements.Buttons.Disabled, GUILayout.Width(30)) 
                    && controller_index > 0)
                {
                    controller_index--;
                    Axis.GUID = Controller.DeviceList[controller_index];
                }

                GUILayout.Label(controller != null ? controller.Name : "<color=#FF0000>Disconnected controller</color>",
                    new GUIStyle(Elements.InputFields.Default) { alignment = TextAnchor.MiddleCenter });

                if (GUILayout.Button(">", controller_index < Controller.NumDevices - 1 ? Elements.Buttons.Default : Elements.Buttons.Disabled, GUILayout.Width(30)) 
                    && controller_index < Controller.NumDevices - 1)
                {
                    controller_index++;
                    Axis.GUID = Controller.DeviceList[controller_index];
                }

                if (controller == null) return;

                GUILayout.EndHorizontal();

                // Draw axis selection
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("<", Axis.Axis > 0 ? Elements.Buttons.Default : Elements.Buttons.Disabled, GUILayout.Width(30)) 
                    && Axis.Axis > 0)
                    Axis.Axis--;

                GUILayout.Label(controller.AxisNames[Axis.Axis], new GUIStyle(Elements.InputFields.Default) { alignment = TextAnchor.MiddleCenter });

                if (GUILayout.Button(">", Axis.Axis < Controller.Get(Axis.GUID).NumAxes - 1 ? Elements.Buttons.Default : Elements.Buttons.Disabled, GUILayout.Width(30)) 
                    && Axis.Axis < Controller.Get(Axis.GUID).NumAxes - 1)
                    Axis.Axis++;

                GUILayout.EndHorizontal();

                // Draw Sensitivity slider
                Axis.Sensitivity = Util.DrawSlider("Sensitivity", Axis.Sensitivity, 0, 5, sens_string, out sens_string);

                // Draw Curvature slider
                Axis.Curvature = Util.DrawSlider("Curvaure", Axis.Curvature, 0, 3, curv_string, out curv_string);

                // Draw Deadzone slider
                Axis.Deadzone = Util.DrawSlider("Deadzone", Axis.Deadzone, 0, 0.5f, dead_string, out dead_string);

                GUILayout.BeginHorizontal();

                // Draw Invert toggle
                Axis.Invert = GUILayout.Toggle(Axis.Invert, "",
                    Util.ToggleStyle,
                    GUILayout.Width(20),
                    GUILayout.Height(20));

                GUILayout.Label("Invert",
                    new GUIStyle(Elements.Labels.Default) { margin = new RectOffset(0, 0, 14, 0) });

                // Draw Raw toggle
                Axis.Smooth = GUILayout.Toggle(Axis.Smooth, "",
                    Util.ToggleStyle,
                    GUILayout.Width(20),
                    GUILayout.Height(20));

                GUILayout.Label("Smooth",
                    new GUIStyle(Elements.Labels.Default) { margin = new RectOffset(0, 0, 14, 0) });

                GUILayout.EndHorizontal();
            }
        }
	// int mm = 32;
	void OnGUI()
	{
		headerTextStyle = headerTextStyle ?? new GUIStyle( EditorStyles.boldLabel );//GUI.skin.label);
		headerTextStyle.fontSize = 16;
		
		linkTextStyle = linkTextStyle ?? new GUIStyle( GUI.skin.label );//GUI.skin.label);
		linkTextStyle.normal.textColor = LinkColor; 
		linkTextStyle.alignment = TextAnchor.MiddleLeft;

		boldTextStyle = boldTextStyle ?? new GUIStyle( GUI.skin.label );//GUI.skin.label);
		boldTextStyle.fontStyle = FontStyle.Bold;
		boldTextStyle.alignment = TextAnchor.MiddleLeft;

		// #if UNITY_4
		// richTextLabel.richText = true;
		// #endif

		advertisementStyle = advertisementStyle ?? new GUIStyle(GUI.skin.button);
		advertisementStyle.normal.background = null;
		
		if(banner != null)
			GUILayout.Label(banner);

		// mm = EditorGUI.IntField(new Rect(Screen.width - 200, 100, 200, 18), "W: ", mm);

		// grr stupid rich text faiiilluuure
		{
			GUILayout.Label("Thank you for purchasing " + ProductName + ". Your support allows us to keep developing this and future tools for everyone.", EditorStyles.wordWrappedLabel);
			GUILayout.Space(2);
			GUILayout.Label("Read these quick \"ProTips\" before starting:", headerTextStyle);
			
			GUILayout.BeginHorizontal();
				GUILayout.Label("1) ", GUILayout.MinWidth(16), GUILayout.MaxWidth(16));	
				GUILayout.Label("Register", boldTextStyle, GUILayout.MinWidth(58), GUILayout.MaxWidth(58));	
				GUILayout.Label("for instant email updates, send your invoice # to", GUILayout.MinWidth(284), GUILayout.MaxWidth(284));	
				if( GUILayout.Button("*****@*****.**", linkTextStyle, GUILayout.MinWidth(142), GUILayout.MaxWidth(142)) )
					Application.OpenURL("mailto:[email protected]?subject=Sign me up for the Beta!");
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
				GUILayout.Label("2) ", GUILayout.MinWidth(16), GUILayout.MaxWidth(16));	
				GUILayout.Label("Report bugs", boldTextStyle, GUILayout.MinWidth(82), GUILayout.MaxWidth(82));	
				GUILayout.Label("to the ProCore Forum at", GUILayout.MinWidth(144), GUILayout.MaxWidth(144));	
				if( GUILayout.Button("www.procore3d.com/forum", linkTextStyle, GUILayout.MinWidth(162), GUILayout.MaxWidth(162)) )
					Application.OpenURL("http://www.procore3d.com/forum");
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
				GUILayout.Label("3) ", GUILayout.MinWidth(16), GUILayout.MaxWidth(16));	
				GUILayout.Label("Customize!", boldTextStyle, GUILayout.MinWidth(74), GUILayout.MaxWidth(74));	
				GUILayout.Label("Click on \"Edit > Preferences\" then \"" + ProductName + "\"", GUILayout.MinWidth(276), GUILayout.MaxWidth(276));	
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
				GUILayout.Label("4) ", GUILayout.MinWidth(16), GUILayout.MaxWidth(16));	
				GUILayout.Label("Documentation", boldTextStyle, GUILayout.MinWidth(102), GUILayout.MaxWidth(102));	
				GUILayout.Label("Tutorials, & more info:", GUILayout.MinWidth(132), GUILayout.MaxWidth(132));	
				if( GUILayout.Button("www.procore3d.com/" + ProductName.ToLower(), linkTextStyle, GUILayout.MinWidth(190), GUILayout.MaxWidth(190)) )
					Application.OpenURL("http://www.procore3d.com/" + ProductName.ToLower());
			GUILayout.EndHorizontal();

			GUILayout.Space(4);

			GUILayout.BeginHorizontal(GUILayout.MaxWidth(50));
				
				GUILayout.Label("Links:", boldTextStyle);

				linkTextStyle.fontStyle = FontStyle.Italic;
				linkTextStyle.alignment = TextAnchor.MiddleCenter;

				if( GUILayout.Button("procore3d.com", linkTextStyle))
					Application.OpenURL("http://www.procore3d.com");

				if( GUILayout.Button("facebook", linkTextStyle))
					Application.OpenURL("http://www.facebook.com/probuilder3d");

				if( GUILayout.Button("twitter", linkTextStyle))
					Application.OpenURL("http://www.twitter.com/probuilder3d");

				linkTextStyle.fontStyle = FontStyle.Normal;
			GUILayout.EndHorizontal();

			GUILayout.Space(4);
		}

		HorizontalLine();

		// always bold the first line (cause it's the version info stuff)
		scroll = EditorGUILayout.BeginScrollView(scroll);
		GUILayout.Label(ProductName + "  |  version: " + ProductVersion + "  |  revision: " + ProductRevision, EditorStyles.boldLabel);
		GUILayout.Label("\n" + changelog);
		EditorGUILayout.EndScrollView();
		
		HorizontalLine();
		
		GUILayout.Label("More ProCore Products", EditorStyles.boldLabel);

		int pad = advertisements.Length * AD_HEIGHT > Screen.width ? 22 : 6;
		adScroll = EditorGUILayout.BeginScrollView(adScroll, false, false, GUILayout.MinHeight(AD_HEIGHT + pad), GUILayout.MaxHeight(AD_HEIGHT + pad));
		GUILayout.BeginHorizontal();

		foreach(AdvertisementThumb ad in advertisements)
		{
			if(ad.url.ToLower().Contains(ProductName.ToLower()))
				continue;
				
			if(GUILayout.Button(ad.guiContent, advertisementStyle,
				GUILayout.MinWidth(AD_HEIGHT), GUILayout.MaxWidth(AD_HEIGHT),
				GUILayout.MinHeight(AD_HEIGHT), GUILayout.MaxHeight(AD_HEIGHT)))
			{
				Application.OpenURL(ad.url);
			}
		}
		GUILayout.EndHorizontal();
		EditorGUILayout.EndScrollView();
		/* shill other products */
	}
Beispiel #14
0
        public override void OnInspectorGUI()
        {
            var data = target as BuildCollection;

            int selectedCount = 0;

            GUILayout.Label("With a Build Collection you can have multiple Build Processes in one list. " +
                            "They can target different platforms and each have their own pre- and post-steps. ",
                            EditorStyles.wordWrappedMiniLabel);
            GUILayout.Label("You can either run one Build Process manually or run a set of selected " +
                            "Build Processes at once. ",
                            EditorStyles.wordWrappedMiniLabel);

            GUILayout.Label("This asset can be accessed by hitting CTRL+SHIFT+C. ",
                            EditorStyles.wordWrappedMiniLabel);

            if (data.mProcesses.Count == 0)
            {
                GUI.color = Color.yellow;
                GUILayout.Label("You should start by adding a Build Process. Hit \"Edit\" to do so. ",
                                EditorStyles.wordWrappedLabel);
                GUI.color = Color.white;
            }

            GUILayout.Label("Build Processes", "BoldLabel");

            GUILayout.BeginVertical("HelpBox", GUILayout.MinHeight(40));
            {
                if (data.mProcesses.Count == 0)
                {
                    GUILayout.Label("None", UBS.Styles.bigHint);
                }
                bool odd = false;
                foreach (var e in data.mProcesses)
                {
                    if (e == null)
                    {
                        break;
                    }
                    selectedCount = UBSWindowBase.DrawBuildProcessEntry(data, e, odd, selectedCount, true);
                    odd           = !odd;
                }
            }
            GUILayout.EndVertical();
            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Edit"))
                {
                    UBSEditorWindow.Init(data);
                }
                GUILayout.Space(5);
                GUI.enabled = selectedCount >= 1;

                if (GUILayout.Button("Run selected builds"))
                {
                    UBSBuildWindow.Init(data);
                }
                GUILayout.Space(5);

                GUI.enabled = selectedCount == 1;
                if (GUILayout.Button("Build and run"))
                {
                    UBSBuildWindow.Init(data, true);
                }
                GUI.enabled = true;

                if (GUILayout.Button("?", GUILayout.Width(32)))
                {
                    EditorUtility.OpenWithDefaultApp("http://kwnetzwelt.net/unity-build-system");
                }
            }
            GUILayout.EndHorizontal();
        }
    private void OnBoundsWindowGUI(SceneView sceneView)
    {
        Rect screenRect = new Rect(Screen.width - BoundsWindowSize.x - 25, Screen.height - BoundsWindowSize.y - 20, BoundsWindowSize.x, BoundsWindowSize.y);

        GUILayout.Window(0, screenRect,
                         (int id) =>
        {
            int LabelWidth = 50;

            GUI.enabled = !Application.isPlaying;
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("xMin", GUILayout.Width(LabelWidth));
            bounds.xMin = EditorGUILayout.FloatField(bounds.xMin);
            EditorGUILayout.LabelField("zMin", GUILayout.Width(LabelWidth));
            bounds.yMin = EditorGUILayout.FloatField(bounds.yMin);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("xMax", GUILayout.Width(LabelWidth));
            bounds.xMax = EditorGUILayout.FloatField(bounds.xMax);
            EditorGUILayout.LabelField("zMax", GUILayout.Width(LabelWidth));
            bounds.yMax = EditorGUILayout.FloatField(bounds.yMax);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("xClose", GUILayout.Width(LabelWidth));
            close.x = EditorGUILayout.FloatField(close.x);
            EditorGUILayout.LabelField("zClose", GUILayout.Width(LabelWidth));
            close.y = EditorGUILayout.FloatField(close.y);
            EditorGUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("CloseScale"))
            {
                Vector3[] vertices = navMeshTri.triangulation.vertices;
                if (vertices != null)
                {
                    for (int i = vertices.Length - 1; i >= 0; i--)
                    {
                        Vector3 vertice = vertices[i];
                        if (Mathf.Abs(vertice.x - bounds.xMin) < close.x)
                        {
                            vertice.x = bounds.xMin;
                        }
                        if (Mathf.Abs(vertice.x - bounds.xMax) < close.x)
                        {
                            vertice.x = bounds.xMax;
                        }
                        if (Mathf.Abs(vertice.z - bounds.yMin) < close.y)
                        {
                            vertice.z = bounds.yMin;
                        }
                        if (Mathf.Abs(vertice.z - bounds.yMax) < close.y)
                        {
                            vertice.z = bounds.yMax;
                        }
                        vertices[i] = vertice;
                    }
                }
                navMeshTri.triangulation = navMeshTri.triangulation;
                EditorUtility.SetDirty(navMeshTri);
            }
            GUILayout.EndHorizontal();
            GUI.enabled = true;
        },
                         "Bounds");
    }
    /// <summary>
    /// Draw the inspector widget.
    /// </summary>

    public override void OnInspectorGUI()
    {
        NGUIEditorTools.SetLabelWidth(80f);
        mAtlas = target as UIAtlas;

        UISpriteData sprite = (mAtlas != null) ? mAtlas.GetSprite(NGUISettings.selectedSprite) : null;

        GUILayout.Space(6f);

        if (mAtlas.replacement != null)
        {
            mType        = AtlasType.Reference;
            mReplacement = mAtlas.replacement;
        }

        GUILayout.BeginHorizontal();
        AtlasType after = (AtlasType)EditorGUILayout.EnumPopup("Atlas Type", mType);

        GUILayout.Space(18f);
        GUILayout.EndHorizontal();

        if (mType != after)
        {
            if (after == AtlasType.Normal)
            {
                mType = AtlasType.Normal;
                OnSelectAtlas(null);
            }
            else
            {
                mType = AtlasType.Reference;
            }
        }

        if (mType == AtlasType.Reference)
        {
            ComponentSelector.Draw <UIAtlas>(mAtlas.replacement, OnSelectAtlas, true);

            GUILayout.Space(6f);
            EditorGUILayout.HelpBox("You can have one atlas simply point to " +
                                    "another one. This is useful if you want to be " +
                                    "able to quickly replace the contents of one " +
                                    "atlas with another one, for example for " +
                                    "swapping an SD atlas with an HD one, or " +
                                    "replacing an English atlas with a Chinese " +
                                    "one. All the sprites referencing this atlas " +
                                    "will update their references to the new one.", MessageType.Info);

            if (mReplacement != mAtlas && mAtlas.replacement != mReplacement)
            {
                NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
                mAtlas.replacement = mReplacement;
                UnityEditor.EditorUtility.SetDirty(mAtlas);
            }
            return;
        }

        //GUILayout.Space(6f);
        Material mat = EditorGUILayout.ObjectField("Material", mAtlas.spriteMaterial, typeof(Material), false) as Material;

        if (mAtlas.spriteMaterial != mat)
        {
            NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
            mAtlas.spriteMaterial = mat;

            // Ensure that this atlas has valid import settings
            if (mAtlas.texture != null)
            {
                NGUIEditorTools.ImportTexture(mAtlas.texture, false, false, !mAtlas.premultipliedAlpha);
            }

            mAtlas.MarkAsChanged();
        }

        if (mat != null)
        {
            TextAsset ta = EditorGUILayout.ObjectField("TP Import", null, typeof(TextAsset), false) as TextAsset;

            if (ta != null)
            {
                // Ensure that this atlas has valid import settings
                if (mAtlas.texture != null)
                {
                    NGUIEditorTools.ImportTexture(mAtlas.texture, false, false, !mAtlas.premultipliedAlpha);
                }

                NGUIEditorTools.RegisterUndo("Import Sprites", mAtlas);
                NGUIJson.LoadSpriteData(mAtlas, ta);
                if (sprite != null)
                {
                    sprite = mAtlas.GetSprite(sprite.name);
                }
                mAtlas.MarkAsChanged();
            }

            float pixelSize = EditorGUILayout.FloatField("Pixel Size", mAtlas.pixelSize, GUILayout.Width(120f));

            if (pixelSize != mAtlas.pixelSize)
            {
                NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
                mAtlas.pixelSize = pixelSize;
            }
        }

        if (mAtlas.spriteMaterial != null)
        {
            Color blue  = new Color(0f, 0.7f, 1f, 1f);
            Color green = new Color(0.4f, 1f, 0f, 1f);

            if (sprite == null && mAtlas.spriteList.Count > 0)
            {
                string spriteName = NGUISettings.selectedSprite;
                if (!string.IsNullOrEmpty(spriteName))
                {
                    sprite = mAtlas.GetSprite(spriteName);
                }
                if (sprite == null)
                {
                    sprite = mAtlas.spriteList[0];
                }
            }

            if (sprite != null)
            {
                if (sprite == null)
                {
                    return;
                }

                Texture2D tex = mAtlas.spriteMaterial.mainTexture as Texture2D;

                if (tex != null)
                {
                    if (!NGUIEditorTools.DrawHeader("Sprite Details"))
                    {
                        return;
                    }

                    NGUIEditorTools.BeginContents();

                    GUILayout.Space(3f);
                    NGUIEditorTools.DrawAdvancedSpriteField(mAtlas, sprite.name, SelectSprite, true);
                    GUILayout.Space(6f);

                    GUI.changed = false;

                    GUI.backgroundColor = green;
                    NGUIEditorTools.IntVector sizeA = NGUIEditorTools.IntPair("Dimensions", "X", "Y", sprite.x, sprite.y);
                    NGUIEditorTools.IntVector sizeB = NGUIEditorTools.IntPair(null, "Width", "Height", sprite.width, sprite.height);

                    EditorGUILayout.Separator();
                    GUI.backgroundColor = blue;
                    NGUIEditorTools.IntVector borderA = NGUIEditorTools.IntPair("Border", "Left", "Right", sprite.borderLeft, sprite.borderRight);
                    NGUIEditorTools.IntVector borderB = NGUIEditorTools.IntPair(null, "Bottom", "Top", sprite.borderBottom, sprite.borderTop);

                    EditorGUILayout.Separator();
                    GUI.backgroundColor = Color.white;
                    NGUIEditorTools.IntVector padA = NGUIEditorTools.IntPair("Padding", "Left", "Right", sprite.paddingLeft, sprite.paddingRight);
                    NGUIEditorTools.IntVector padB = NGUIEditorTools.IntPair(null, "Bottom", "Top", sprite.paddingBottom, sprite.paddingTop);

                    if (GUI.changed)
                    {
                        NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);

                        sprite.x      = sizeA.x;
                        sprite.y      = sizeA.y;
                        sprite.width  = sizeB.x;
                        sprite.height = sizeB.y;

                        sprite.paddingLeft   = padA.x;
                        sprite.paddingRight  = padA.y;
                        sprite.paddingBottom = padB.x;
                        sprite.paddingTop    = padB.y;

                        sprite.borderLeft   = borderA.x;
                        sprite.borderRight  = borderA.y;
                        sprite.borderBottom = borderB.x;
                        sprite.borderTop    = borderB.y;

                        MarkSpriteAsDirty();
                    }
                    NGUIEditorTools.EndContents();
                }

                if (NGUIEditorTools.previousSelection != null)
                {
                    GUI.backgroundColor = Color.green;

                    if (GUILayout.Button("<< Return to " + NGUIEditorTools.previousSelection.name))
                    {
                        NGUIEditorTools.SelectPrevious();
                    }
                    GUI.backgroundColor = Color.white;
                }
            }
        }
    }
Beispiel #17
0
			public void Dispose()
			{
				GUILayout.EndHorizontal();
            }
Beispiel #18
0
	/// <summary>
	/// A window that displayss the recorded logs.
	/// </summary>
	/// <param name="windowID">Window ID.</param>
	void ConsoleWindow (int windowID)
	{
		GUI.contentColor = Color.white;
		if (GUI.Button(new Rect(0, 0, 18, 18), new GUIContent("x")))
			show = false;
		
		GUILayout.BeginHorizontal();
		
		
		if (GUILayout.Button(new GUIContent("Reset Socket Connection (you can also press Shift+Ctrl+R)", "Reset the socket connection and accept new connections."))) {
			//Debug.Log("resetting");
			gameObject.SendMessage("OnRestartServer");	
			//logs.Clear();
		}
		
		/*GUILayout.Label("Port number:");
		newPortStr = GUILayout.TextField(newPortStr);
		int tmpPort = 42209;
		if (int.TryParse(newPortStr, out tmpPort))
			GlobalVariables.portNumber = tmpPort;
		else
			newPortStr = GlobalVariables.portNumber.ToString();*/
		GUILayout.EndHorizontal();
		
		/*GUILayout.BeginHorizontal();
		if (GUILayout.Button(new GUIContent("Return to main screen"))) {
			//Debug.Log("resetting");
			//gameObject.SendMessage("OnRestartServer");
			gameObject.SendMessage("Disconnect");
			Application.LoadLevel("MainScreen");
			//logs.Clear();
		}
		GUILayout.Label("\t\tExits this scene and returns to the main screen.");
		GUILayout.EndHorizontal();*/
		
		//GUILayout.BeginHorizontal();
		//GUILayout.EndHorizontal();
		
		GUILayout.BeginHorizontal();
		if (GUILayout.Button(new GUIContent("Save this task to file"))) {
			saveFileDialog();
		}
		if (GUILayout.Button(new GUIContent("Load task from file"))) {
			loadFileDialog();
		}
		GUILayout.EndHorizontal();
		
		
		GUILayout.BeginHorizontal();
		GUILayout.Label("\nActive\nStates:");
		//construct string of all states
		string st = "";
		foreach (State s in GlobalVariables.activeStates.getCopy())
			st += s.stateName + ", ";
		GUI.TextArea(new Rect(85,85,800,100), st, 200);
		GUILayout.EndHorizontal();
		
		GUILayout.Space(45);
		
		GUILayout.BeginHorizontal();
		GUILayout.Label("\nActive\nReflexes:");
		//construct string of all reflexes
		st = "";
		foreach (Reflex s in GlobalVariables.activeReflexes.getCopy())
			st += s.reflexName + ", ";
		GUI.TextArea(new Rect(85,185,800,100), st, 200);
		GUILayout.EndHorizontal();
		
		GUILayout.Space(65);

		GUILayout.BeginHorizontal();
		if (GUILayout.Button(new GUIContent("Reset States")))
		{
			GlobalVariables.activeStates.TryReset();
		}
		if (GUILayout.Button(new GUIContent("Reset Reflexes")))
		{
			GlobalVariables.activeReflexes.TryReset();
		}
		/*if (GUILayout.Button(new GUIContent("test")))
		{
			GlobalVariables.messageQueue.Add(AIMessage.fromString("setReflex,r1,s1\n"));
			GlobalVariables.messageQueue.Add(AIMessage.fromString("setReflex,r2,s1\n"));
			GlobalVariables.messageQueue.Add(AIMessage.fromString("setReflex,r3,s1\n"));
			GlobalVariables.messageQueue.Add(AIMessage.fromString("setReflex,r4,s1\n"));
		}*/
		GUILayout.EndHorizontal();
		
		GUILayout.BeginHorizontal();
		GlobalVariables.sendNotificationOnReflexFirings = GUILayout.Toggle(GlobalVariables.sendNotificationOnReflexFirings, "Send notifications when reflexes fire?");
		
		GlobalVariables.spokenCommandFieldVisible = GUILayout.Toggle(GlobalVariables.spokenCommandFieldVisible, "Show command textbox");
		
		GlobalVariables.viewControlsVisible = GUILayout.Toggle(GlobalVariables.viewControlsVisible, "Show view controls");
		GUILayout.EndHorizontal();

		GUILayout.BeginHorizontal();
		GlobalVariables.showDetailedVisionMarkers = GUILayout.Toggle(GlobalVariables.showDetailedVisionMarkers, "Show markers ('*') for detailed vision sensors?");
		//GUILayout.EndHorizontal();

		//GUILayout.BeginHorizontal();
		GlobalVariables.showPeripheralVisionMarkers = GUILayout.Toggle(GlobalVariables.showPeripheralVisionMarkers, "Show markers ('o') for peripheral vision sensors?");
		GUILayout.EndHorizontal();
		
		GUILayout.BeginHorizontal();
		//get the main guy
		bodyController[] mainGuy = UnityEngine.MonoBehaviour.FindObjectsOfType(typeof(bodyController)) as bodyController[];
		GUILayout.Label("Current coordinates of PAGI guy: " + mainGuy[0].rigidbody2D.position.ToString() + "\t\t");
		if (GUILayout.Button(new GUIContent("Reset PAGI guy to (0,0)"))) {
			mainGuy[0].rigidbody2D.position = new Vector2(0,0);
			leftHandController[] leftHand = UnityEngine.MonoBehaviour.FindObjectsOfType(typeof(leftHandController)) as leftHandController[];
			rightHandController[] rightHand = UnityEngine.MonoBehaviour.FindObjectsOfType(typeof(rightHandController)) as rightHandController[];
			leftHand[0].rigidbody2D.position = new Vector2(-1f, 1f);
			rightHand[0].rigidbody2D.position = new Vector2(1f, 1f);	
			mainGuy[0].rigidbody2D.rotation = 0;
			leftHand[0].rigidbody2D.rotation = 0;
			rightHand[0].rigidbody2D.rotation = 0;
			mainGuy[0].rigidbody2D.velocity = Vector2.zero;
			leftHand[0].rigidbody2D.velocity = Vector2.zero;
			rightHand[0].rigidbody2D.velocity = Vector2.zero;
			mainGuy[0].rigidbody2D.AddForce(Vector2.zero); //forces update of rotation
		}
		GUILayout.EndHorizontal();
		
		GUILayout.BeginHorizontal();
		GUILayout.Label("Speed (0=paused, 1=normal speed):");	
		//GUILayout.EndHorizontal();
		//GUILayout.BeginHorizontal();
		if (GUILayout.Button(new GUIContent("<", "Slows down time"))) {
			Time.timeScale = Mathf.Round(10f*Mathf.Max(0f, Time.timeScale-0.1f))/10f;
		}
		GUILayout.Label("  "+Time.timeScale.ToString());
		if (GUILayout.Button(new GUIContent(">", "Speeds up time"))) {
			Time.timeScale = Mathf.Round(10f*Mathf.Min(10f, Time.timeScale+0.1f))/10f;
		}
		//GUILayout.EndHorizontal();
		
		//GUILayout.BeginHorizontal();
		GUILayout.Label("\t\tGravity:");	
		if (GUILayout.Button(new GUIContent("<", "Slows down time"))) {
			Physics2D.gravity = new Vector2(0, Physics2D.gravity.y-1);
		}
		GUILayout.Label("  "+Physics2D.gravity.y);
		if (GUILayout.Button(new GUIContent(">", "Speeds up time"))) {
			Physics2D.gravity = new Vector2(0, Physics2D.gravity.y+1);
		}
		if (GUILayout.Button(new GUIContent("zero", "Sets gravity to zero"))) {
			Physics2D.gravity = new Vector2(0, 0);
		}
		if (GUILayout.Button(new GUIContent("normal", "Sets gravity to its normal level"))) {
			Physics2D.gravity = new Vector2(0, -9.81f);
		}
		GUILayout.EndHorizontal();
		
		/*GUILayout.BeginHorizontal();
		PhysicsMaterial2D pm2d = mainGuy[0].rigidbody2D.collider2D.sharedMaterial;
		GUILayout.Label("World friction (is normal):");	
		//GUILayout.EndHorizontal();
		//GUILayout.BeginHorizontal();
		if (GUILayout.Button(new GUIContent("<", "Slows down time"))) {
			pm2d.friction -= 0.1f;
		}
		GUILayout.Label("  " + pm2d.friction.ToString());
		if (GUILayout.Button(new GUIContent(">", "Speeds up time"))) {
			pm2d.friction += 0.1f;
		}
		GUILayout.EndHorizontal();*/
		
		
		// Allow the window to be dragged by its title bar.
		GUI.DragWindow(windowRect);
		
	}
        private void OnGUI()
        {
            if (this.BlwDef == null || this.EyeDef == null || this.ElDef == null || this.MthDef == null)
            {
                return;
            }

            GUILayout.Box("", GUILayout.Width(220), GUILayout.Height(15 * (this._blendShapeCount + 1)));
            Rect screenRect = new Rect(10, 10, 190, 15 * (this._blendShapeCount + 1));

            GUILayout.BeginArea(screenRect);

            var sliderIndex = 0;

            //BLW_DEF
            for (var defIndex = 0; defIndex < this.BlwDef.sharedMesh.blendShapeCount; defIndex++)
            {
                sliderIndex = defIndex;
                GUILayout.BeginHorizontal();

                //BlendShape名
                var labelName = this.BlwDef.sharedMesh.GetBlendShapeName(defIndex);
                labelName = labelName.Substring(labelName.IndexOf('.') + 1);
                GUILayout.Label(labelName, this._labelTitleStyle);

                //スライダー
                this._sliderValues[sliderIndex] = GUILayout.HorizontalSlider(this._sliderValues[sliderIndex], 0f, 100f);

                //スライダーの値
                GUILayout.Label(((int)this._sliderValues[sliderIndex]).ToString("#0"), this._labelValueStyle);

                GUILayout.EndHorizontal();

                //スライダーの値をBlendShapeに反映
                this.BlwDef.SetBlendShapeWeight(defIndex, this._sliderValues[sliderIndex]);
            }

            //EYE_DEF, EL_DEF
            var adjustCount = this.BlwDef.sharedMesh.blendShapeCount;

            for (var defIndex = 0; defIndex < this.EyeDef.sharedMesh.blendShapeCount; defIndex++)
            {
                sliderIndex = adjustCount + defIndex;
                GUILayout.BeginHorizontal();

                //BlendShape名
                var labelName = this.EyeDef.sharedMesh.GetBlendShapeName(defIndex);
                labelName = labelName.Substring(labelName.IndexOf('.') + 1);
                GUILayout.Label(labelName, this._labelTitleStyle);

                //スライダー
                this._sliderValues[sliderIndex] = GUILayout.HorizontalSlider(this._sliderValues[sliderIndex], 0f, 100f);

                //スライダーの値
                GUILayout.Label(((int)this._sliderValues[sliderIndex]).ToString("#0"), this._labelValueStyle);

                GUILayout.EndHorizontal();

                //スライダーの値をBlendShapeに反映
                this.EyeDef.SetBlendShapeWeight(defIndex, this._sliderValues[sliderIndex]);
                this.ElDef.SetBlendShapeWeight(defIndex, this._sliderValues[sliderIndex]);
            }

            //MTH_DEF
            adjustCount += this.EyeDef.sharedMesh.blendShapeCount;
            for (int defIndex = 0; defIndex < this.MthDef.sharedMesh.blendShapeCount; defIndex++)
            {
                sliderIndex = adjustCount + defIndex;
                GUILayout.BeginHorizontal();

                //BlendShape名
                var labelName = this.MthDef.sharedMesh.GetBlendShapeName(defIndex);
                labelName = labelName.Substring(labelName.IndexOf('.') + 1);
                GUILayout.Label(labelName, this._labelTitleStyle);

                //スライダー
                this._sliderValues[sliderIndex] = GUILayout.HorizontalSlider(this._sliderValues[sliderIndex], 0f, 100f);

                //スライダーの値
                GUILayout.Label(((int)this._sliderValues[sliderIndex]).ToString("#0"), this._labelValueStyle);

                GUILayout.EndHorizontal();

                //スライダーの値をBlendShapeに反映
                this.MthDef.SetBlendShapeWeight(defIndex, this._sliderValues[sliderIndex]);
            }

            GUILayout.EndArea();
        }
    void OnGUI()
    {
        GUI.skin = m_guiSkin;

        GUILayout.Space(40);

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        GUILayout.Label(string.Format("isRunningOnOUYASupportedHardware: {0}",
                                      OuyaSDK.isRunningOnOUYASupportedHardware()),
                        GUILayout.Width(300));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));

        GUILayout.FlexibleSpace();

        int deviceId = PlayerNum;

        GUILayout.BeginVertical();
        GUILayout.Label("OUYA Axises:");
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.AXIS_LS_X", OuyaSDK.OuyaInput.GetAxis(deviceId, OuyaController.AXIS_LS_X)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.AXIS_LS_Y", OuyaSDK.OuyaInput.GetAxis(deviceId, OuyaController.AXIS_LS_Y)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.AXIS_RS_X", OuyaSDK.OuyaInput.GetAxis(deviceId, OuyaController.AXIS_RS_X)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.AXIS_RS_Y", OuyaSDK.OuyaInput.GetAxis(deviceId, OuyaController.AXIS_RS_Y)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.AXIS_L2", OuyaSDK.OuyaInput.GetAxis(deviceId, OuyaController.AXIS_L2)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.AXIS_R2", OuyaSDK.OuyaInput.GetAxis(deviceId, OuyaController.AXIS_R2)));
        GUILayout.EndVertical();

        GUILayout.FlexibleSpace();

        GUILayout.BeginVertical();
        GUILayout.Label("OUYA Buttons:");
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_O", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_O)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_U", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_U)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_Y", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_Y)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_A", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_A)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_L1", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_L1)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_R1", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_R1)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_L3", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_L3)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_R3", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_R3)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_DPAD_UP", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_DPAD_UP)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_DPAD_DOWN", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_DPAD_DOWN)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_DPAD_RIGHT", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_DPAD_RIGHT)));
        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_DPAD_LEFT", OuyaSDK.OuyaInput.GetButton(deviceId, OuyaController.BUTTON_DPAD_LEFT)));

        if (OuyaSDK.OuyaInput.GetButtonDown(deviceId, OuyaController.BUTTON_MENU))
        {
            m_menuDetected = DateTime.Now + TimeSpan.FromSeconds(1);
        }

        GUILayout.Label(string.Format("{0}={1}", "OuyaController.BUTTON_MENU", DateTime.Now < m_menuDetected));
        GUILayout.EndVertical();

        GUILayout.FlexibleSpace();

        GUI.skin = null;
        GUILayout.BeginVertical();
        for (int index = 0; index < OuyaController.MAX_CONTROLLERS; ++index)
        {
            if (GUILayout.Button(string.Format(PlayerNum == index ? "[JOY{0}]{1}" : "JOY{0}{1}", index, OuyaSDK.OuyaInput.IsControllerConnected(index) ? " |=" : " |X"), GUILayout.Height(60)))
            {
                PlayerNum = index;
                UpdatePlayerButtons();
            }
        }
        GUILayout.EndVertical();

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Hide Cursor"))
        {
            OuyaController.showCursor(false);
        }

        GUILayout.FlexibleSpace();

        GUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));

        GUILayout.FlexibleSpace();

        GUI.skin = m_guiSkin;
        GUILayout.BeginHorizontal(GUILayout.Width(300));
        GUILayout.Label("Controllers:");
        GUILayout.BeginVertical();
        GUILayout.Label(string.Format("{0}={1}", 1, m_controller1));
        GUILayout.Label(string.Format("{0}={1}", 2, m_controller2));
        GUILayout.Label(string.Format("{0}={1}", 3, m_controller3));
        GUILayout.Label(string.Format("{0}={1}", 4, m_controller4));
        GUILayout.Label(string.Format("{0}={1}", 5, m_controller5));
        GUILayout.Label(string.Format("{0}={1}", 6, m_controller6));
        GUILayout.Label(string.Format("{0}={1}", 7, m_controller7));
        GUILayout.Label(string.Format("{0}={1}", 8, m_controller8));
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        GUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));

        GUILayout.FlexibleSpace();

        GUILayout.BeginHorizontal();

        GUILayout.Label(m_label);

        GUILayout.FlexibleSpace();

        GUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        GUILayout.EndHorizontal();

        int buttonId = 0;

        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        for (; buttonId < 7 && buttonId < m_controllerButtons.Count; ++buttonId)
        {
            Texture2D texture = m_controllerButtons[buttonId];
            if (null != texture)
            {
                GUILayout.Button(texture);
            }
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        for (; buttonId < m_controllerButtons.Count; ++buttonId)
        {
            Texture2D texture = m_controllerButtons[buttonId];
            if (null != texture)
            {
                GUILayout.Button(texture);
            }
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();

        GUI.skin = null;
    }
        void Buttons()
        {
            bool wasGUIEnabled = GUI.enabled;

            GUI.enabled &= !EditorApplication.isPlayingOrWillChangePlaymode;

            if (Lightmapping.lightingDataAsset && !Lightmapping.lightingDataAsset.isValid)
            {
                EditorGUILayout.HelpBox(Lightmapping.lightingDataAsset.validityErrorMessage, MessageType.Warning);
            }

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

            Rect rect = GUILayoutUtility.GetRect(Styles.ContinuousBakeLabel, GUIStyle.none);

            EditorGUI.BeginProperty(rect, Styles.ContinuousBakeLabel, m_WorkflowMode);

            bool iterative = m_WorkflowMode.intValue == (int)Lightmapping.GIWorkflowMode.Iterative;

            EditorGUI.BeginChangeCheck();
            iterative = GUILayout.Toggle(iterative, Styles.ContinuousBakeLabel);

            if (EditorGUI.EndChangeCheck())
            {
                m_WorkflowMode.intValue = (int)(iterative ? Lightmapping.GIWorkflowMode.Iterative : Lightmapping.GIWorkflowMode.OnDemand);
            }

            EditorGUI.EndProperty();

            using (new EditorGUI.DisabledScope(iterative))
            {
                // Bake button if we are not currently baking
                bool showBakeButton = iterative || !Lightmapping.isRunning;
                if (showBakeButton)
                {
                    if (EditorGUI.ButtonWithDropdownList(Styles.BuildLabel, s_BakeModeOptions, BakeDropDownCallback, GUILayout.Width(170)))
                    {
                        DoBake();

                        // DoBake could've spawned a save scene dialog. This breaks GUI on mac (Case 490388).
                        // We work around this with an ExitGUI here.
                        GUIUtility.ExitGUI();
                    }
                }
                // Cancel button if we are currently baking
                else
                {
                    // Only show Force Stop when using the PathTracer backend
                    if (LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.ProgressiveCPU &&
                        m_EnabledBakedGI.boolValue &&
                        GUILayout.Button("Force Stop", GUILayout.Width(kButtonWidth)))
                    {
                        Lightmapping.ForceStop();
                    }
                    if (GUILayout.Button("Cancel", GUILayout.Width(kButtonWidth)))
                    {
                        Lightmapping.Cancel();
                        UsabilityAnalytics.Track("/LightMapper/Cancel");
                    }
                }
            }

            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            GUI.enabled = wasGUIEnabled;
        }
Beispiel #22
0
    public void OnGUI()
    {
        GUILayout.BeginArea(
            m_screenRect,
            m_name,
            GUI.skin.window
            );
        GUILayout.BeginHorizontal();
        for (int parentIndex = 0; parentIndex < m_currentDirectoryParts.Length; ++parentIndex)
        {
            if (parentIndex == m_currentDirectoryParts.Length - 1)
            {
                GUILayout.Label(m_currentDirectoryParts[parentIndex], CentredText);
            }
            else if (GUILayout.Button(m_currentDirectoryParts[parentIndex]))
            {
                string parentDirectoryName = m_currentDirectory;
                for (int i = m_currentDirectoryParts.Length - 1; i > parentIndex; --i)
                {
                    parentDirectoryName = Path.GetDirectoryName(parentDirectoryName);
                }
                SetNewDirectory(parentDirectoryName);
            }
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        m_scrollPosition = GUILayout.BeginScrollView(
            m_scrollPosition,
            false,
            true,
            GUI.skin.horizontalScrollbar,
            GUI.skin.verticalScrollbar,
            GUI.skin.box
            );
        m_selectedDirectory = GUILayoutx.SelectionList(
            m_selectedDirectory,
            m_directoriesWithImages,
            DirectoryDoubleClickCallback
            );
        if (m_selectedDirectory > -1)
        {
            m_selectedFile = m_selectedNonMatchingDirectory = -1;
        }
        m_selectedNonMatchingDirectory = GUILayoutx.SelectionList(
            m_selectedNonMatchingDirectory,
            m_nonMatchingDirectoriesWithImages,
            NonMatchingDirectoryDoubleClickCallback
            );
        if (m_selectedNonMatchingDirectory > -1)
        {
            m_selectedDirectory = m_selectedFile = -1;
        }
        GUI.enabled    = BrowserType == FileBrowserType.File;
        m_selectedFile = GUILayoutx.SelectionList(
            m_selectedFile,
            m_filesWithImages,
            FileDoubleClickCallback
            );
        GUI.enabled = true;
        if (m_selectedFile > -1)
        {
            m_selectedDirectory = m_selectedNonMatchingDirectory = -1;
        }
        GUI.enabled = false;
        GUILayoutx.SelectionList(
            -1,
            m_nonMatchingFilesWithImages
            );
        GUI.enabled = true;
        GUILayout.EndScrollView();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Cancel", GUILayout.Width(50)))
        {
            m_callback(null);
        }
        if (BrowserType == FileBrowserType.File)
        {
            GUI.enabled = m_selectedFile > -1;
        }
        else
        {
            if (SelectionPattern == null)
            {
                GUI.enabled = m_selectedDirectory > -1;
            }
            else
            {
                GUI.enabled = m_selectedDirectory > -1 ||
                              (
                    m_currentDirectoryMatches &&
                    m_selectedNonMatchingDirectory == -1 &&
                    m_selectedFile == -1
                              );
            }
        }
        if (GUILayout.Button("Select", GUILayout.Width(50)))
        {
            if (BrowserType == FileBrowserType.File)
            {
                m_callback(Path.Combine(m_currentDirectory, m_files[m_selectedFile]));
            }
            else
            {
                if (m_selectedDirectory > -1)
                {
                    m_callback(Path.Combine(m_currentDirectory, m_directories[m_selectedDirectory]));
                }
                else
                {
                    m_callback(m_currentDirectory);
                }
            }
        }
        GUI.enabled = true;
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        if (Event.current.type == EventType.Repaint)
        {
            SwitchDirectoryNow();
        }
    }
        void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);

            long totalMemorySize            = 0;
            int  lightmapCount              = 0;
            Dictionary <Vector2, int> sizes = new Dictionary <Vector2, int>();
            bool directionalLightmapsMode   = false;
            bool shadowmaskMode             = false;

            foreach (LightmapData ld in LightmapSettings.lightmaps)
            {
                if (ld.lightmapColor == null)
                {
                    continue;
                }
                lightmapCount++;

                Vector2 texSize = new Vector2(ld.lightmapColor.width, ld.lightmapColor.height);
                if (sizes.ContainsKey(texSize))
                {
                    sizes[texSize]++;
                }
                else
                {
                    sizes.Add(texSize, 1);
                }

                totalMemorySize += TextureUtil.GetStorageMemorySizeLong(ld.lightmapColor);
                if (ld.lightmapDir)
                {
                    totalMemorySize         += TextureUtil.GetStorageMemorySizeLong(ld.lightmapDir);
                    directionalLightmapsMode = true;
                }
                if (ld.shadowMask)
                {
                    totalMemorySize += TextureUtil.GetStorageMemorySizeLong(ld.shadowMask);
                    shadowmaskMode   = true;
                }
            }
            StringBuilder sizesString = new StringBuilder();

            sizesString.Append(lightmapCount);
            sizesString.Append((directionalLightmapsMode ? " Directional" : " Non-Directional"));
            sizesString.Append(" Lightmap");
            if (lightmapCount != 1)
            {
                sizesString.Append("s");
            }
            if (shadowmaskMode)
            {
                sizesString.Append(" with Shadowmask");
                if (lightmapCount != 1)
                {
                    sizesString.Append("s");
                }
            }

            bool first = true;

            foreach (var s in sizes)
            {
                sizesString.Append(first ? ": " : ", ");
                first = false;
                if (s.Value > 1)
                {
                    sizesString.Append(s.Value);
                    sizesString.Append("x");
                }
                sizesString.Append(s.Key.x);
                sizesString.Append("x");
                sizesString.Append(s.Key.y);
                sizesString.Append("px");
            }
            sizesString.Append(" ");

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            GUILayout.Label(sizesString.ToString(), Styles.LabelStyle);
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            GUILayout.Label(EditorUtility.FormatBytes(totalMemorySize), Styles.LabelStyle);
            GUILayout.Label((lightmapCount == 0 ? "No Lightmaps" : ""), Styles.LabelStyle);
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            if (LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten)
            {
                GUILayout.BeginVertical();
                GUILayout.Label("Memory Usage: " + Lightmapping.ComputeTotalMemoryUsageInMB().ToString("0.0") + " MB", Styles.LabelStyle);
                GUILayout.Label("Occupied Texels: " + InternalEditorUtility.CountToString(Lightmapping.occupiedTexelCount), Styles.LabelStyle);
                if (Lightmapping.isRunning)
                {
                    int numLightmapsInView             = 0;
                    int numConvergedLightmapsInView    = 0;
                    int numNotConvergedLightmapsInView = 0;

                    int numLightmapsNotInView             = 0;
                    int numConvergedLightmapsNotInView    = 0;
                    int numNotConvergedLightmapsNotInView = 0;

                    int numInvalidConvergenceLightmaps = 0;
                    int numLightmaps = LightmapSettings.lightmaps.Length;
                    for (int i = 0; i < numLightmaps; ++i)
                    {
                        LightmapConvergence lc = Lightmapping.GetLightmapConvergence(i);
                        if (!lc.IsValid())
                        {
                            numInvalidConvergenceLightmaps++;
                            continue;
                        }

                        if (Lightmapping.GetVisibleTexelCount(i) > 0)
                        {
                            numLightmapsInView++;
                            if (lc.IsConverged())
                            {
                                numConvergedLightmapsInView++;
                            }
                            else
                            {
                                numNotConvergedLightmapsInView++;
                            }
                        }
                        else
                        {
                            numLightmapsNotInView++;
                            if (lc.IsConverged())
                            {
                                numConvergedLightmapsNotInView++;
                            }
                            else
                            {
                                numNotConvergedLightmapsNotInView++;
                            }
                        }
                    }
                    EditorGUILayout.LabelField("Lightmaps in view: " + numLightmapsInView, Styles.LabelStyle);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.LabelField("Converged: " + numConvergedLightmapsInView, Styles.LabelStyle);
                    EditorGUILayout.LabelField("Not Converged: " + numNotConvergedLightmapsInView, Styles.LabelStyle);
                    EditorGUI.indentLevel -= 1;
                    EditorGUILayout.LabelField("Lightmaps not in view: " + numLightmapsNotInView, Styles.LabelStyle);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.LabelField("Converged: " + numConvergedLightmapsNotInView, Styles.LabelStyle);
                    EditorGUILayout.LabelField("Not Converged: " + numNotConvergedLightmapsNotInView, Styles.LabelStyle);
                    EditorGUI.indentLevel -= 1;
                }
                float bakeTime    = Lightmapping.GetLightmapBakeTimeTotal();
                float mraysPerSec = Lightmapping.GetLightmapBakePerformanceTotal();
                if (mraysPerSec >= 0.0)
                {
                    GUILayout.Label("Bake Performance: " + mraysPerSec.ToString("0.00") + " mrays/sec", Styles.LabelStyle);
                }
                if (!Lightmapping.isRunning)
                {
                    float bakeTimeRaw = Lightmapping.GetLightmapBakeTimeRaw();
                    if (bakeTime >= 0.0)
                    {
                        int time  = (int)bakeTime;
                        int timeH = time / 3600;
                        time -= 3600 * timeH;
                        int timeM = time / 60;
                        time -= 60 * timeM;
                        int timeS = time;

                        int timeRaw  = (int)bakeTimeRaw;
                        int timeRawH = timeRaw / 3600;
                        timeRaw -= 3600 * timeRawH;
                        int timeRawM = timeRaw / 60;
                        timeRaw -= 60 * timeRawM;
                        int timeRawS = timeRaw;

                        int oHeadTime  = Math.Max(0, (int)(bakeTime - bakeTimeRaw));
                        int oHeadTimeH = oHeadTime / 3600;
                        oHeadTime -= 3600 * oHeadTimeH;
                        int oHeadTimeM = oHeadTime / 60;
                        oHeadTime -= 60 * oHeadTimeM;
                        int oHeadTimeS = oHeadTime;


                        GUILayout.Label("Total Bake Time: " + timeH.ToString("0") + ":" + timeM.ToString("00") + ":" + timeS.ToString("00"), Styles.LabelStyle);
                        if (Unsupported.IsDeveloperMode())
                        {
                            GUILayout.Label("(Raw Bake Time: " + timeRawH.ToString("0") + ":" + timeRawM.ToString("00") + ":" + timeRawS.ToString("00") + ", Overhead: " + oHeadTimeH.ToString("0") + ":" + oHeadTimeM.ToString("00") + ":" + oHeadTimeS.ToString("00") + ")", Styles.LabelStyle);
                        }
                    }
                }
                GUILayout.EndVertical();
            }

            GUILayout.EndVertical();
        }
Beispiel #24
0
    private void InfoGUI()
    {
        if (idxSelectedInCurrent == -1)
        {
            return;
        }
        if (EditorGUIUtility.isProSkin)
        {
            GUI.contentColor = oldColor;
        }
        else
        {
            GUI.backgroundColor = oldColor * alpha;
        }
        GUILayout.BeginVertical(GUILayout.Width(390));
        GUILayout.Space(5f);
        GUILayout.BeginHorizontal();
        btnStyle.alignment = TextAnchor.MiddleCenter;
        if (!string.IsNullOrEmpty(selectedRevision) && GUILayout.Button(new GUIContent(string.Format("{0} ({1})", selectedVersion, selectedRevision), versionTooltip), btnStyle))
        {
            Application.OpenURL(string.Format(releaseUrlBeta, selectedRevision, "download.html"));
        }
        if (hasReleaseNotes && GUILayout.Button(
                new GUIContent("Release Notes", rnTooltip), btnStyle))
        {
            Application.OpenURL(wwwReleaseNotes.url);
        }
        if (hasTorrent && GUILayout.Button(
                new GUIContent("Torrent", torrentTooltip), btnStyle))
        {
            StartTorrent();
        }
        GUILayout.EndHorizontal();
        Dictionary <string, Dictionary <string, string> > dict = null;

        if (!string.IsNullOrEmpty(selectedRevision))
        {
            GUILayout.BeginHorizontal();
            idxOS = GUILayout.SelectionGrid(idxOS, hasLinux ? titlesOSLinux : titlesOS, hasLinux ? 3 : 2,
                                            btnStyle);
            switch (idxOS)
            {
            case 0:
                dict = dictIniWin;
                break;

            case 1:
                dict = dictIniOSX;
                break;

            case 2:
                dict = dictIniLinux;
                break;
            }
            GUILayout.EndHorizontal();
        }
        if (dict != null)
        {
            GUILayout.BeginVertical();
            GUILayout.Space(5f);
            btnStyle.alignment = TextAnchor.MiddleLeft;
            foreach (var key in dict.Keys)
            {
                if (GUILayout.Button(new GUIContent(dict[key]["title"], dict[key]["description"]), btnStyle))
                {
                    var url = dict[key]["url"].StartsWith("http") ? dict[key]["url"] :
                              string.Format(releaseUrlBeta, selectedRevision, dict[key]["url"]);
                    EditorGUIUtility.systemCopyBuffer = url;
                    ShowNotification(new GUIContent("URL copied to the clipboard"));
                }
            }
            GUILayout.EndVertical();
        }
        GUILayout.EndVertical();
    }
        private void DrawClipsList()
        {
            bool isOriginal = (_selectedController == SelectedController.Original);

            AnimationClip[] disabledList;
            AnimationClip[] enabledList;

            if (isOriginal)
            {
                enabledList  = _originalAnimatorClips;
                disabledList = _developmentAnimatorClips;
            }
            else
            {
                disabledList = _originalAnimatorClips;
                enabledList  = _developmentAnimatorClips;
            }

            for (int i = 0; i < enabledList.Length; i++)
            {
                if (isOriginal)
                {
                    if (enabledList[i]
                        .name.IndexOf(_ogSearchText, System.StringComparison.OrdinalIgnoreCase) < 0)
                    {
                        continue;
                    }
                }
                else
                {
                    if (enabledList[i]
                        .name.IndexOf(_devSearchText, System.StringComparison.OrdinalIgnoreCase) < 0)
                    {
                        continue;
                    }
                }

                bool exists = CheckExists(enabledList[i], disabledList);

                GUIContent labelContent = new GUIContent()
                {
                    text = enabledList[i].name
                };

                if (exists)
                {
                    labelContent.image = EditorGUIUtility.FindTexture(SYNCED_CLIP_ICON);
                }
                else
                {
                    if (isOriginal)
                    {
                        labelContent.image = EditorGUIUtility.FindTexture(NOT_SYNCED_CLIP_ICON);
                    }
                    else
                    {
                        labelContent.image = EditorGUIUtility.FindTexture(NOT_SYNCED_DEVCLIP_ICON);
                    }
                }

                GUILayout.BeginHorizontal("Box");
                GUILayout.Label(labelContent);

                if (GUILayout.Button(new GUIContent()
                {
                    image = EditorGUIUtility.FindTexture(SELECT_ICON)
                }, GUILayout.MaxWidth(30f)))
                {
                    EditorGUIUtility.PingObject(enabledList[i]);
                }

                GUIContent btnContent = new GUIContent();
                if (isOriginal)
                {
                    if (exists)
                    {
                        btnContent.tooltip = "Remove clip from developer animator controller.";
                        btnContent.image   = EditorGUIUtility.FindTexture(REMOVE_CLIP_ICON);
                        if (GUILayout.Button(btnContent, GUILayout.MaxWidth(30f)))
                        {
                            ReplaceLayer(_devAnimatorController, RemoveMotion(enabledList[i]));
                            return;
                        }
                    }
                    else
                    {
                        btnContent.tooltip = "Copy clip to developer animator controller.";
                        btnContent.image   = EditorGUIUtility.FindTexture(ADD_CLIP_ICON);
                        if (GUILayout.Button(btnContent, GUILayout.MaxWidth(30f)))
                        {
                            _devAnimatorController.AddMotion(enabledList[i]);
                        }
                    }
                }
                else
                {
                    if (!exists)
                    {
                        btnContent.tooltip = "Sync clip to main animator controller.";
                        btnContent.image   = EditorGUIUtility.FindTexture(SYNC_CLIP_ICON);
                        if (GUILayout.Button(btnContent, GUILayout.MaxWidth(30f)))
                        {
                            _ogAnimatorController.AddMotion(enabledList[i]);
                        }
                    }
                    btnContent.tooltip = "Remove clip from developer animator controller.";
                    btnContent.image   = EditorGUIUtility.FindTexture(DELETE_CLIP_ICON);
                    if (GUILayout.Button(btnContent, GUILayout.MaxWidth(30f)))
                    {
                        ReplaceLayer(_devAnimatorController, RemoveMotion(enabledList[i]));
                        return;
                    }
                }
                GUILayout.EndHorizontal();
            }
        }
Beispiel #26
0
        public override void OnGUI()
        {
            GUILayout.BeginHorizontal(Styles.AuthHeaderBoxStyle);
            {
                GUILayout.BeginVertical(GUILayout.Width(16));
                {
                    GUILayout.Space(9);
                    GUILayout.Label(Styles.BigLogo, GUILayout.Height(20), GUILayout.Width(20));
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical();
                {
                    GUILayout.Space(11);
                    GUILayout.Label(Title, EditorStyles.boldLabel);
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(Styles.PublishViewSpacingHeight);

            EditorGUI.BeginDisabledGroup(isBusy);
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.BeginVertical();
                    {
                        GUILayout.Label(SelectedOwnerLabel);
                        selectedOwner = EditorGUILayout.Popup(selectedOwner, owners);
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical(GUILayout.Width(8));
                    {
                        GUILayout.Space(20);
                        GUILayout.Label("/");
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical();
                    {
                        GUILayout.Label(RepositoryNameLabel);
                        repoName = EditorGUILayout.TextField(repoName);
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();

                GUILayout.Label(DescriptionLabel);
                repoDescription = EditorGUILayout.TextField(repoDescription);
                GUILayout.Space(Styles.PublishViewSpacingHeight);

                GUILayout.BeginVertical();
                {
                    GUILayout.BeginHorizontal();
                    {
                        togglePrivate = GUILayout.Toggle(togglePrivate, CreatePrivateRepositoryLabel);
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(Styles.PublishViewSpacingHeight);
                        var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage;
                        GUILayout.Label(repoPrivacyExplanation, Styles.LongMessageStyle);
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();

                GUILayout.Space(Styles.PublishViewSpacingHeight);

                if (error != null)
                {
                    GUILayout.Label(error, Styles.ErrorLabel);
                }

                GUILayout.FlexibleSpace();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();
                    EditorGUI.BeginDisabledGroup(!IsFormValid);
                    if (GUILayout.Button(PublishViewCreateButton))
                    {
                        isBusy = true;

                        var organization = owners[selectedOwner] == username ? null : owners[selectedOwner];

                        Client.CreateRepository(new NewRepository(repoName)
                        {
                            Private = togglePrivate,
                        }, (repository, ex) =>
                        {
                            Logger.Trace("Create Repository Callback");

                            if (ex != null)
                            {
                                error  = ex.Message;
                                isBusy = false;
                                return;
                            }

                            if (repository == null)
                            {
                                Logger.Warning("Returned Repository is null");
                                isBusy = false;
                                return;
                            }

                            GitClient.RemoteAdd("origin", repository.CloneUrl)
                            .Then(GitClient.Push("origin", Repository.CurrentBranch.Value.Name))
                            .ThenInUI(Finish)
                            .Start();
                        }, organization);
                    }
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(10);
            }
            EditorGUI.EndDisabledGroup();
        }
    private void OnGUI()
    {
        //头像
        GUILayout.Space(10);
        NIEditorUtility.DrawAuthorSummary();
        GUILayout.Space(10);

        //选择目标目录
        GUILayout.Space(10);
        GUILayout.BeginHorizontal();
        {
            GUILayout.Space(5);
            GUIStyle style = EditorStyles.textArea;
            style.fontStyle = FontStyle.Bold;
            style.alignment = TextAnchor.MiddleLeft;
            GUILayout.Label(FILE_ROOT_PATH, style, GUILayout.Height(25));

            if (GUILayout.Button("SetPath", GUILayout.MaxWidth(65f)))
            {
                string tempPath = NIEditorUtility.BrowseFolder();
                if (!string.IsNullOrEmpty(tempPath))
                {
                    FILE_ROOT_PATH = tempPath;
                    Refresh();
                }
                return;
            }

            if (GUILayout.Button("ResetPath", GUILayout.MaxWidth(75f)))
            {
                FILE_ROOT_PATH = Application.dataPath + "/../" + CONFIG_JSON_FOLER_NAME;
                Refresh();
                return;
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(10);

        //内容
        GUI.backgroundColor = new Color32(150, 200, 255, 255);
        GUILayout.BeginVertical("AS TextArea", GUILayout.Height(500));
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Config File Name", EditorStyles.toolbarButton);
            GUILayout.Label("Operation", EditorStyles.toolbarButton);
            GUILayout.EndHorizontal();

            _scrollPos = GUILayout.BeginScrollView(_scrollPos, GUILayout.Height(470));
            for (int i = 0; i < mFilesPathList.Count; i++)
            {
                string fileName = Path.GetFileNameWithoutExtension(mFilesPathList[i]);

                GUILayout.BeginHorizontal();
                {
                    GUIStyle style = EditorStyles.textArea;
                    style.fontStyle = FontStyle.Bold;
                    style.alignment = TextAnchor.MiddleLeft;
                    GUILayout.Label(fileName, style, GUILayout.Height(25));

                    DrawCreateBtn(mFilesPathList[i], fileName);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
        }
        GUILayout.EndVertical();

        //刷新
        GUILayout.Space(10f);
        GUILayout.BeginHorizontal();
        {
            GUILayout.Space(10);
            if (GUILayout.Button("Refresh", GUILayout.MaxWidth(60f)))
            {
                Refresh();
                return;
            }
            GUILayout.Space(2);
            GUILayout.Label("To refresh Config Files");
        }
        GUILayout.EndHorizontal();

        //创建全部
        GUILayout.Space(10);
        GUILayout.BeginHorizontal();
        {
            GUILayout.Space(10);
            if (GUILayout.Button("Create All", GUILayout.MaxWidth(80f)))
            {
                for (int i = 0; i < mFilesPathList.Count; i++)
                {
                    string fileName = Path.GetFileNameWithoutExtension(mFilesPathList[i]);
                    CreateCsConfigFile(mFilesPathList[i], fileName, CONFIG_FOLDER_NAME);
                }
                return;
            }
            GUILayout.Space(2);
            GUILayout.Label("To Create All Config Files");
        }
        GUILayout.EndHorizontal();

        //生成到目标路径
        GUILayout.BeginVertical();
        {
            GUILayout.Space(10);

            GUILayout.Label("生成到目标路径:");

            GUI.color = Color.white;
            GUIStyle style = EditorStyles.textArea;
            style.fontStyle = FontStyle.Bold;
            style.alignment = TextAnchor.MiddleLeft;
            GUILayout.Label(Application.dataPath + "/../" + CONFIG_FOLDER_NAME, style, GUILayout.Height(25));
        }
        GUILayout.EndVertical();
    }