Skip to content

Commit

Permalink
Add timeout option
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjunbiao committed May 8, 2023
1 parent 2c5c752 commit eb88e9a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Changelog

## [0.1.0] Initial Release

## [0.1.1] Add timeout option
4 changes: 2 additions & 2 deletions Editor/API/HDAProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public static IEnumerator GetHDAHeaderRoutine(string hdaName, Action<dynamic> co
}
}

public static void ProcessHDAAsync(this HDAProcessorPreset preset, Action<ZipArchive> completed, Action failed = null, int timeout = 120)
public static void ProcessHDAAsync(this HDAProcessorPreset preset, Action<ZipArchive> completed, Action failed = null, int timeout = 300)
{
ProcessHDAAsync(preset.hda, preset.parms, completed, failed, timeout);
}

public static void ProcessHDAAsync(string hda, IEnumerable<HouParm> parms, Action<ZipArchive> completed,
Action failed = null, int timeout = 120)
Action failed = null, int timeout = 300)
{
Uri uri = GetUri(hda);
List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
Expand Down
1 change: 1 addition & 0 deletions Editor/ScriptableObject/HDAProcessorPreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class HDAProcessorPreset : ScriptableObject
public IntParm[] intParms;
public FloatParm[] floatParms;
public StringParm[] stringParms;
public int timeout = 300;

public IEnumerable<HouParm> parms
{
Expand Down
4 changes: 3 additions & 1 deletion Editor/ScriptableObject/HDAProcessorPresetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ public override void OnInspectorGUI()
parm.GUILayout();
}

target.timeout = EditorGUILayout.IntField("Timeout(s)", target.timeout);

if (GUILayout.Button("Cook"))
{
HDAProcessor.ProcessHDAAsync(target,
zip =>
{
string outputDir = EditorUtility.SaveFolderPanel("Output Dir", Application.dataPath, "Output");
zip.ExtractToDirectory(outputDir, true);
});
}, timeout: target.timeout);
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions Editor/Window/HDAProcessorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class HDAProcessorWindow : EditorWindow
private string[] hdaNames = new string[0];
private HouParm[] parms;
private float progress = 1.0f;
private static int timeout = 300;

private string hda => hdas[hdaIdx];

Expand Down Expand Up @@ -72,6 +73,8 @@ private void OnGUI()
parm.GUILayout();
}
}

timeout = Mathf.Max(30, EditorGUILayout.IntField("Timeout(s)", timeout));

if (GUILayout.Button("Save As Preset"))
{
Expand All @@ -84,9 +87,9 @@ private void OnGUI()
EditorGUI.ProgressBar(rect, progress, "Cooking");
}
else if (GUILayout.Button("Cook"))
{
Cook();
}
{
Cook();
}
}

void CreateHDAProcessorPreset()
Expand Down Expand Up @@ -121,7 +124,7 @@ void Cook()
AssetDatabase.Refresh();
}
progress = 1.0f;
});
}, timeout: timeout);
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.pum4ch3n.harpoon",
"version": "0.1.0",
"version": "0.1.1",
"displayName": "Harpoon",
"description": "Harpoon Unity Plugin",
"unity": "2018.1",
Expand Down

0 comments on commit eb88e9a

Please sign in to comment.