This system allows for dynamic generation of surveys from JSON configuration files or ScriptableObjects in Unity. It works within VR on a world canvas and is depending on the edia.core package.
- Configurable: Use the same JSON config for multiple surveys.
- Dynamic UI Generation: Creates UI survey components based on JSON configuration. No need to create prefabs manually.
- Automatic Results Collection: Collects results automatically, logs them to a JSON file.
- State Preservation: Automatically saves user input when navigating between pages, allowing users to go back and modify their answers without losing progress.
Edia_Survey.mp4
Import the package via the Unity Package Manager.
Use the following path: 'https://github.com/edia-toolbox/edia_survey.git?path=Assets/com.edia.survey'
- Drag the prefab 'SurveyPanel' under a canvas object.
- Define your survey by setting up the JSON config file. (see below)
- Drag this file into the 'Survey json' field.
- (Optional) Set the Main Color in the inspector.
- Link the
onFinishedUnityEvent to any cleanup or transition logic, theOnFinishedResultalso provides the results as JSON string.
- Generate an scriptable object for the survey configuration via 'Create -> EDIA -> Survey -> Survey Configuration' and drag it into the 'Survey Configuration' field.
- Call the
Init()method on theSurveyManagerscript to initialize the survey using the JSON file or ScriptableObject assigned in the inspector. - Call the
Init(string json)method on theSurveyManagerscript to initialize the survey from a JSON string.
{
"surveyId": "my_unique_survey_id",
"pages": [
{
"id": "page_01",
"components": [
{
...
},
{
...
}
]
},
{
"id": "page_02",
"components": [
{
...
}
]
},
...
]
}Each component type in the JSON configuration defines a specific UI element in the survey.
The type field defines the type of component and is used to determine which UI element to create.
For displaying section headers.
{
"id": "header",
"type": "header",
"text": "User Feedback"
}For displaying information blocks.
{
"id": "info",
"type": "text",
"text": "Welcome to the Survey. \n\nPlease provide your feedback."
}For Likert-scale questions using toggles.
{
"id": "q_2",
"type": "likert_scale",
"label": "Debugging is awesome?",
"options": ["Strongly disagree", "Disagree", "somewhat disagree", "Neutral", "Somewhat agree", "Agree", "Strongly agree"]
}For Likert-scale questions with smilie indicators. Supports 3,5 and 7 options.
{
"id": "q_3",
"type": "likert_faces",
"label": "How happy are you with the service?",
"options": ["Very Unhappy", "Unhappy", "Neutral", "Happy", "Very Happy"]
}A grid-style Likert scale with multiple sub-questions (rows) and shared options (columns).
{
"id": "q_1",
"type": "likert_matrix",
"label": "Please rate the following topics",
"options": ["Very Poor", "Poor", "Average", "Good", "Excellent"],
"subQuestions": ["User Interface", "Performance", "Documentation"]
}For questions with a list of answers and checkboxes/toggles. Supports single or multiple selection.
{
"id": "q_5",
"type": "qa_list",
"label": "Which of these features do you like? (Multiple allowed)",
"options": ["Dynamic Loading", "Automatic Navigation", "Scientific Scales", "Page Counter"],
"allowMultiple": true
}For a single question with multiple options presented in a dropdown.
{
"id": "q_7",
"type": "qa_dropdown",
"label": "Please select your department",
"options": ["Engineering", "Design", "Marketing", "HR"]
}Visual Analogue Scale variant supports continuous sliders.
Increments: whole numbers (snaps on value) and floating point (analog handle).
IndicatorTypes: None,Lines, Bands, Numbers]
{
"id": "q_8",
"type": "vas_slider",
"label": "VAS Slider Variant",
"text": "Please use the slider to rate your experience",
"leftLabel": "Low",
"rightLabel": "High",
"minValue": "0.0",
"maxValue": "10.0",
"indicatorType": "Lines"
}Visual Analogue Scale variant supports discrete marker placement.
IndicatorTypes: None,Lines, Bands, Numbers]
{
"id": "q_9",
"type": "vas_markers",
"label": "VAS Marker Variant",
"text": "Please tick anywhere on the scale to place a marker",
"leftLabel": "Low",
"rightLabel": "High",
"minValue": "0",
"maxValue": "10",
"indicatorType": "Bands"
}For displaying a final message.
{
"id": "end",
"type": "finish_survey",
"text": "Thank you for participating in our survey!",
"label": "Finish"
}For navigation (Next, Back). This is added automatically to each page.
When the survey is finished, the OnSurveyFinishedResult(string) event is triggered, providing the results as a JSON string.
You can use the SurveyResult helper methods to parse this data back into a usable format:
public void OnResultsReceived(string json) {
// Parse JSON into a SurveyResult object
SurveyResult result = SurveyResult.Parse(json);
// Get as a Dictionary for easy lookup (componentId as key)
Dictionary<string, string> dict = result.ToDictionary();
if (dict.TryGetValue("my_question_id", out string val)) {
Debug.Log($"User answered: {val}");
}
// Or get as a List of KeyValuePairs (requested by user)
List<KeyValuePair<string, string>> pairs = result.ToKeyValuePairList();
}See the Samples/ExampleSurvey/SurveyResultExample.cs for a complete implementation.
Example JSON output:
{
"SurveyId": "my_unique_survey_id",
"results": [
{
"componentId": "q_1",
"value": "User Interface: Good; Performance: Very Poor; Documentation: Excellent"
},
{
"componentId": "q_2",
"value": "Agree"
},
{
"componentId": "q_3",
"value": "Very Happy"
},
{
"componentId": "q_5",
"value": "Scientific Scales, Page Counter"
},
{
"componentId": "q_6",
"value": "Unity 6"
},
{
"componentId": "q_7",
"value": "Engineering"
},
{
"componentId": "q_8",
"value": "19"
},
{
"componentId": "q_9",
"value": "8"
}
]
}This project uses the Unity Test Runner for quality assurance. To run tests, open the Test Runner window in Unity (Window > General > Test Runner).
- EditMode Tests: Located in
Assets/com.edia.survey/Tests/Editor. These tests run in the Unity Editor and are used for testing logic that doesn't require a running scene (e.g., data serialization). - PlayMode Tests: Located in
Assets/com.edia.survey/Tests/Runtime. These tests run in a scene and can be used to test MonoBehaviour interactions and full survey flows.
The project uses Assembly Definitions (.asmdef) to manage dependencies:
Edia.Survey.Runtime: The main runtime code.Edia.Survey.Tests.Editor: Editor-only tests.Edia.Survey.Tests.Runtime: Runtime/PlayMode tests.
To add new tests, create a new script in the appropriate Tests subfolder and ensure it is part of the corresponding assembly.










