Initial commit: Unity WordConnect project

This commit is contained in:
2025-08-01 19:12:05 +08:00
commit f14db75802
3503 changed files with 448337 additions and 0 deletions

View File

@ -0,0 +1,74 @@
// // ©2015 - 2025 Candy Smith
// // All rights reserved
// // Redistribution of this software is strictly not allowed.
// // Copy of this software can be obtained from unity asset store only.
// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// // FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// // THE SOFTWARE.
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
using WordsToolkit.Scripts.Services.Ads.AdUnits;
namespace WordsToolkit.Scripts.Settings.Editor
{
[CustomPropertyDrawer(typeof(AdElement))]
public class AdElementDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
// Create a new VisualElement
var root = new VisualElement();
// Add placementId field
var placementIdField = new PropertyField(property.FindPropertyRelative("placementId"));
root.Add(placementIdField);
// Add adTypeScriptable field
var adTypeScriptableProperty = property.FindPropertyRelative("adReference");
var adTypeScriptableField = new PropertyField(adTypeScriptableProperty);
root.Add(adTypeScriptableField);
// Add popup field
var popupField = new PropertyField(property.FindPropertyRelative("popup"));
root.Add(popupField);
adTypeScriptableField.RegisterValueChangeCallback(evt =>
{
// Retrieve the selected adType from the AdTypeScriptable
var adTypeScriptableObject = (AdReference)adTypeScriptableProperty.objectReferenceValue;
if (adTypeScriptableObject != null && adTypeScriptableObject.adType == EAdType.Interstitial)
{
popupField.visible = true;
}
else
{
if (root.Contains(popupField))
{
popupField.visible = false;
}
}
});
// Add popup field only if adType is not Rewarded
if (adTypeScriptableProperty != null)
{
var adTypeScriptableObject = (AdReference)adTypeScriptableProperty.objectReferenceValue;
if (adTypeScriptableObject != null && adTypeScriptableObject.adType == EAdType.Rewarded)
{
root.Remove(popupField);
}
}
// Return the root VisualElement
return root;
}
}
}
#endif

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 68d4eb51aed94d4a9b4209a928083b4f
timeCreated: 1709623047

View File

@ -0,0 +1,65 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
namespace WordsToolkit.Scripts.Settings.Editor
{
[CustomPropertyDrawer(typeof(AdSetting))]
public class AdSettingDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
// Create a new VisualElement
var root = new VisualElement();
// Create a foldout
var foldout = new Foldout { text = property.displayName, value = false };
root.Add(foldout);
// Add fields to the foldout
var nameField = new PropertyField(property.FindPropertyRelative("name"), "Name");
var enableField = new PropertyField(property.FindPropertyRelative("enable"), "Enable");
var testInEditorField = new PropertyField(property.FindPropertyRelative("testInEditor"), "Test In Editor");
var platformsField = new PropertyField(property.FindPropertyRelative("platforms"), "Platforms");
var appIdField = new PropertyField(property.FindPropertyRelative("appId"), "App ID");
var adsHandlerField = new PropertyField(property.FindPropertyRelative("adsHandler"), "Ads Handler");
var adElementsField = new PropertyField(property.FindPropertyRelative("adElements"), "Ad Elements");
foldout.Add(nameField);
foldout.Add(enableField);
foldout.Add(testInEditorField);
foldout.Add(platformsField);
foldout.Add(appIdField);
foldout.Add(adsHandlerField);
foldout.Add(adElementsField);
// Callback to update the state of the fields and foldout style
void UpdateFieldsState(bool isEnabled)
{
nameField.SetEnabled(isEnabled);
testInEditorField.SetEnabled(isEnabled);
platformsField.SetEnabled(isEnabled);
appIdField.SetEnabled(isEnabled);
adsHandlerField.SetEnabled(isEnabled);
adElementsField.SetEnabled(isEnabled);
foldout.style.color = isEnabled ? Color.white : Color.grey;
}
// Initial state update
UpdateFieldsState(property.FindPropertyRelative("enable").boolValue);
// Register callback to update fields and foldout style when 'enable' changes
enableField.RegisterValueChangeCallback(evt =>
{
UpdateFieldsState(evt.changedProperty.boolValue);
});
// Return the root VisualElement
return root;
}
}
}
#endif

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1e8f074cdfc548fb8b0722de46a5f56b
timeCreated: 1737623180

View File

@ -0,0 +1,19 @@
{
"name": "CandySmith.Settings.Editor",
"rootNamespace": "",
"references": [
"GUID:d3bf71b33c0c04eb9bc1a8d6513d76bb",
"GUID:00dd4a7ac8c24c898083910c81898ecc"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2e755fc9023fa4372a757a229ad32c45
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,86 @@
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor;
using UnityEditor.UIElements;
namespace WordsToolkit.Scripts.Settings.Editor
{
[CustomPropertyDrawer(typeof(TutorialShowCondition))]
public class TutorialShowConditionDrawer : PropertyDrawer
{
private static StyleSheet styleSheet;
private void LoadStyleSheet()
{
if (styleSheet == null)
{
styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>(
"Assets/WordConnectGameToolkit/Scripts/Settings/Editor/TutorialShowConditionDrawer.uss");
if (styleSheet == null)
{
Debug.LogWarning("Could not load TutorialShowConditionDrawer.uss");
}
}
}
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
LoadStyleSheet();
var root = new VisualElement();
if (styleSheet != null)
{
root.styleSheets.Add(styleSheet);
}
var fieldsContainer = new VisualElement();
fieldsContainer.AddToClassList("tutorial-fields-container");
// Add label
var propertyLabel = new Label("Tutorial Condition");
propertyLabel.AddToClassList("property-label");
fieldsContainer.Add(propertyLabel);
// Create fields container
var fieldsGroup = new VisualElement();
fieldsGroup.AddToClassList("fields-container");
var conditionProperty = property.FindPropertyRelative("showCondition");
var conditionEnum = new EnumField();
conditionEnum.BindProperty(conditionProperty);
conditionEnum.style.flexGrow = 1;
var levelProperty = property.FindPropertyRelative("level");
var levelInt = new IntegerField();
levelInt.BindProperty(levelProperty);
// Add fields to the group
fieldsGroup.Add(conditionEnum);
fieldsGroup.Add(levelInt);
// Add fields group to the main container
fieldsContainer.Add(fieldsGroup);
// Add container to root
root.Add(fieldsContainer);
// Register value change callbacks
conditionEnum.RegisterValueChangedCallback(evt =>
{
// Refresh the level field visibility based on condition
var condition = (ETutorialShowCondition)evt.newValue;
levelInt.style.display = condition == ETutorialShowCondition.Level ?
DisplayStyle.Flex : DisplayStyle.None;
property.serializedObject.ApplyModifiedProperties();
});
// Initial setup of level field visibility
var initialCondition = (ETutorialShowCondition)conditionProperty.enumValueIndex;
levelInt.style.display = initialCondition == ETutorialShowCondition.Level ?
DisplayStyle.Flex : DisplayStyle.None;
return root;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2325f08eaa0b4c128ab6bb851d423377
timeCreated: 1749296625