Skip to content

Commit

Permalink
Fix undo and get conway panel pagination in a half decent state
Browse files Browse the repository at this point in the history
[CI BUILD]
  • Loading branch information
andybak committed Apr 30, 2021
1 parent a3c7791 commit 4b2ce50
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ MonoBehaviour:
m_OrderedPageButtons: []
m_PrevButton: {fileID: 0}
m_NextButton: {fileID: 0}
ButtonsPerPage: 16
m_ColorTransitionDuration: 0
ButtonPrefab: {fileID: 7630606763700834929, guid: 56c1524891cb7c44fb711233648ba9ff,
type: 3}
Expand Down
15 changes: 7 additions & 8 deletions Assets/Polyhydra/Scripts/PolyhydraPopUpWindowBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ namespace TiltBrush
{
public abstract class PolyhydraPopUpWindowBase : PopUpWindow
{
public int ButtonsPerPage = 16;

[SerializeField] protected float m_ColorTransitionDuration;
[SerializeField] protected GameObject ButtonPrefab;
[NonSerialized] public int FirstButtonIndex = 0;

protected float m_ColorTransitionValue;
protected Material m_ColorBackground;
Expand Down Expand Up @@ -93,7 +96,7 @@ protected void CreateButtons()
rButton.transform.localScale = Vector3.one * .3f;

Renderer rButtonRenderer = rButton.GetComponent<Renderer>();
rButtonRenderer.material.mainTexture = GetButtonIcon(buttonIndex);
rButtonRenderer.material.mainTexture = GetButtonTexture(buttonIndex);

PolyhydraThingButton rButtonScript = rButton.GetComponent<PolyhydraThingButton>();
rButtonScript.ButtonIndex = buttonIndex;
Expand All @@ -104,9 +107,9 @@ protected void CreateButtons()
}
}

internal Texture2D GetButtonIcon(int buttonIndex)
protected Texture2D GetButtonTexture(int buttonIndex)
{
return Resources.Load<Texture2D>(GetButtonTexturePath(buttonIndex));
return Resources.Load<Texture2D>(GetButtonTexturePath(buttonIndex + FirstButtonIndex));
}

protected abstract string GetButtonTexturePath(int i);
Expand Down Expand Up @@ -136,10 +139,6 @@ public void PolyhydraThingButtonPressed(int ButtonIndex)
HandleButtonPress(ButtonIndex);
ParentPanel.RebuildPoly();
}

protected Texture2D GetButtonTexture(int buttonIndex)
{
return Resources.Load<Texture2D>(GetButtonTexturePath(buttonIndex));
}

}
}
6 changes: 2 additions & 4 deletions Assets/Polyhydra/Scripts/PolyhydraPopUpWindowConwayOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public class PolyhydraPopUpWindowConwayOps : PolyhydraPopUpWindowBase
{

[NonSerialized] protected int OpStackIndex = 0;
[NonSerialized] public int ButtonsPerPage = 16;
[NonSerialized] public int FirstButtonIndex = 0;


protected override string[] GetButtonList()
Expand Down Expand Up @@ -59,8 +57,8 @@ public override void HandleButtonPress(int relativeButtonIndex)

ops[OpStackIndex] = op;
ParentPanel.PolyhydraModel.ConwayOperators = ops;
ParentPanel.ButtonsConwayOps[OpStackIndex].SetButtonTexture(GetButtonTexture(absoluteButtonIndex));

ParentPanel.ButtonsConwayOps[OpStackIndex].SetButtonTexture(GetButtonTexture(relativeButtonIndex));
ParentPanel.ButtonsConwayOps[OpStackIndex].SetDescriptionText(GetButtonList()[relativeButtonIndex]);
if (opConfig.usesAmount)
{
ParentPanel.SlidersConwayOps[OpStackIndex * 2].gameObject.SetActive(true);
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/EditorSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ EditorSettings:
m_EnableTextureStreamingInEditMode: 1
m_EnableTextureStreamingInPlayMode: 1
m_AsyncShaderCompilation: 1
m_EnterPlayModeOptionsEnabled: 0
m_EnterPlayModeOptionsEnabled: 1
m_EnterPlayModeOptions: 3
m_ShowLightmapResolutionOverlay: 1
m_UseLegacyProbeSampleCount: 1
Expand Down

0 comments on commit 4b2ce50

Please sign in to comment.