Skip to content

Commit

Permalink
Layout problem fix for Unity 2022 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardMalkhasyan committed Jun 28, 2024
1 parent a9eee90 commit 1830e76
Show file tree
Hide file tree
Showing 9 changed files with 470 additions and 460 deletions.
File renamed without changes.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
56 changes: 56 additions & 0 deletions Assets/Plugins/SerializableDictionary/Demo/Scripts/Example.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using UnityEngine;
using UnityEngine.UI;

namespace ProjectTools.Demo
{
public interface MyTestInterface
{
void TestMethod();
}

public class Example : MonoBehaviour, MyTestInterface
{
[SerializeField] private Text GeorgeLabel;
[SerializeField] private Image GeorgeImage;

[SerializeField] private Text ThemisLabel;
[SerializeField] private Image ThemisImage;

[SerializeField] private SerializableDictionary<int, string> intToStringDictionary;
[SerializeField] private SerializableDictionary<string, Color> stringToColorDictionary;
[SerializeField] private SerializableDictionary<string, int[]> stringToIntArrayDictionary;

[SerializeField] private InterfaceHolder<MyTestInterface> serializedInterface;

[SerializeField] private SerializableDictionary<string, InterfaceHolder<MyTestInterface>> stringToInterfaceDictionary;

private const string GeorgeName = "George";
private const string ThemisName = "Themis";

private void Start()
{
TestSetup();
serializedInterface.Value.TestMethod();
}

public void TestSetup()
{
GeorgeLabel.text = intToStringDictionary[0];
ThemisLabel.text = intToStringDictionary[1];

GeorgeImage.color = stringToColorDictionary[GeorgeName];
ThemisImage.color = stringToColorDictionary[ThemisName];
}

[ContextMenu("Call")]
public void CallTestMethodOfInterface()
{
stringToInterfaceDictionary["interface_1"].Value.TestMethod();
}

public void TestMethod()
{
Debug.Log($"Test method call from {this}");
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ void ExpandablePanel()
void DisplayName()
{
GUI.color = Color.white;

#if UNITY_2022_1_OR_NEWER
var labelRect = headerRect;
labelRect.x += 12;
GUI.Label(labelRect, prop.displayName);
#else
GUI.Label(headerRect, prop.displayName);
#endif

GUI.color = Color.white;
GUI.skin.label.fontSize = 12;
GUI.skin.label.fontStyle = FontStyle.Normal;
Expand Down
54 changes: 0 additions & 54 deletions Assets/Scripts/Example.cs

This file was deleted.

2 changes: 1 addition & 1 deletion ProjectSettings/EditorBuildSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ EditorBuildSettings:
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/Scenes/GameScene.unity
path: Assets/Plugins/SerializableDictionary/Demo/DemoScene.unity
guid: 2cda990e2423bbf4892e6590ba056729
m_configObjects: {}

0 comments on commit 1830e76

Please sign in to comment.