public void ObjectSelectorEditor_CurrentValue()
        {
            ObjectSelectorEditor underTest = GetNewObjectSelectorEditor();

            underTest.SetValue("some Value");
            Assert.True(underTest.EqualsToValue("some Value"));
            Assert.False(underTest.EqualsToValue("some other value"));
        }
        public void ObjectSelectorEditor_Constructor()
        {
            ObjectSelectorEditor underTest = GetNewObjectSelectorEditor();

            Assert.NotNull(underTest);
            Assert.True(underTest.EqualsToValue(null));
            Assert.False(underTest.SubObjectSelector);

            underTest = GetNewObjectSelectorEditor(true);
            Assert.True(underTest.SubObjectSelector);
        }
Exemplo n.º 3
0
    /// <summary>
    /// Object Menu GUI 표시
    /// </summary>
    private void DrawObjectMenuGUI()
    {
        if (!_grid.MapEditorStart)
        {
            return;
        }

        UnityEditor.Handles.BeginGUI();
        GUILayout.BeginArea(new Rect(20, 20, 100 * _grid.ObjectCacheCount + 40, 190));

        Color initBoxTextColor = GUI.skin.box.normal.textColor;
        Color initBtnTextColor = GUI.skin.button.normal.textColor;
        Color initBgColor      = GUI.backgroundColor;

        GUI.skin.box.normal.textColor = Color.white;
        GUI.backgroundColor           = new Color(0.2f, 0, 0, 0.3f);
        GUI.Box(new Rect(20, 20, 100 * _grid.ObjectCacheCount + 20, 170), "Object Menu");

        GUI.skin.button.normal.textColor = Color.white;

        // Object List
        Texture2D t2D = null;

        for (int index = 0; index < _grid.ObjectCacheCount; ++index)
        {
            // 캐시 오브젝트 선택
            if (GUI.Button(new Rect(40 + 100 * index, 130, 80, 20), "선택"))
            {
                if (_grid._cachedObjects[index] != null)
                {
                    _grid._curSelectIndex = index;
                    _grid.OnChangeGuideObject(_grid._cachedObjects[index]);
                }
            }
            // 캐시 오브젝트 변경
            if (GUI.Button(new Rect(40 + 100 * index, 155, 80, 20), "변경"))
            {
                // 새 Object를 Cache 목록에 올린다.
                ObjectSelectorEditor selector = (ObjectSelectorEditor)EditorWindow.GetWindow(typeof(ObjectSelectorEditor), true, "Object Selector");
                selector.Init(ObjectSelectorEditor.BrickPrefabPath, index, (valueIndex, value) =>
                {
                    // 현재 목록의 이전 선택 정보를 삭제
                    if (_grid._curSelectIndex == valueIndex)
                    {
                        _grid._curSelectIndex = -1;
                    }

                    _grid._cachedObjects[valueIndex] = (GameObject)value;

                    EditorUtility.SetDirty(_grid);
                });
            }

            if (_grid._cachedObjects.Count <= index || _grid._cachedObjects[index] == null)
            {
                continue;
            }

            t2D = AssetPreview.GetAssetPreview(_grid._cachedObjects[index]);
            if (t2D != null)
            {
                GUI.DrawTexture(new Rect(40 + 100 * index, 45, 80, 80), t2D);
            }
        }

        // 선택한 캐시 오브젝트 표시
        if (_grid._curSelectIndex != -1 && _grid._cachedObjects[_grid._curSelectIndex] != null)
        {
            GUI.DrawTexture(new Rect(40 + 100 * _grid._curSelectIndex, 40, 5, 5), Texture2D.whiteTexture);
        }

        GUI.skin.box.normal.textColor    = initBoxTextColor;
        GUI.skin.button.normal.textColor = initBtnTextColor;
        GUI.backgroundColor = initBgColor;

        GUILayout.EndArea();
        UnityEditor.Handles.EndGUI();
    }
 // Constructors
 public Selector(ObjectSelectorEditor editor)
 {
 }
	// Constructors
	public Selector(ObjectSelectorEditor editor) {}
        public void ObjectSelectorEditor_GetEditStyle()
        {
            ObjectSelectorEditor underTest = GetNewObjectSelectorEditor();

            Assert.Equal(UITypeEditorEditStyle.DropDown, underTest.GetEditStyle(null));
        }