Skip to content

Commit

Permalink
Merge pull request #42 from VirtueSky/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
VirtueSky authored Dec 12, 2024
2 parents c3d1542 + 30188fd commit 66f70be
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 281 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
### 1: Download the repo and drop it into folder `Assets`
### 2: Add the line below to `Packages/manifest.json`

for version `3.2.1`
for version `3.2.2`
```csharp
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.2.1",
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.2.2",
```

## Includes modules
Expand Down
32 changes: 0 additions & 32 deletions VirtueSky/ControlPanel/CPIapDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,44 +71,14 @@ public static void OnDrawIap(Rect position)
MessageType.Warning);
#endif
GUILayout.Space(10);
// Handles.DrawAAPolyLine(3, new Vector3(210, GUILayoutUtility.GetLastRect().y + 10),
// new Vector3(position.width, GUILayoutUtility.GetLastRect().y + 10));
CPUtility.GuiLine(2);
GUILayout.Space(10);

if (GUILayout.Button("Create Iap Purchase Product Event"))
{
#if VIRTUESKY_IAP
IapWindowEditor.CreateIapProductEvent();

#else
Debug.LogError("Add scripting define symbols ( VIRTUESKY_IAP ) to use IAP");
#endif
}

if (GUILayout.Button("Create Iap Is Purchase Product Event"))
{
#if VIRTUESKY_IAP
IapWindowEditor.CreateIsPurchaseProductEvent();

#else
Debug.LogError("Add scripting define symbols ( VIRTUESKY_IAP ) to use IAP");
#endif
}


GUILayout.Space(10);
// Handles.DrawAAPolyLine(3, new Vector3(210, GUILayoutUtility.GetLastRect().y + 10),
// new Vector3(position.width, GUILayoutUtility.GetLastRect().y + 10));
CPUtility.GuiLine(2);
GUILayout.Space(10);
CPUtility.DrawHeader("Install Sdk");
GUILayout.Space(10);
CPUtility.DrawButtonInstallPackage("Install In App Purchasing", "Remove In App Purchasing",
ConstantPackage.PackageNameInAppPurchase, ConstantPackage.MaxVersionInAppPurchase);
GUILayout.Space(10);
// Handles.DrawAAPolyLine(3, new Vector3(210, GUILayoutUtility.GetLastRect().y + 10),
// new Vector3(position.width, GUILayoutUtility.GetLastRect().y + 10));
CPUtility.GuiLine(2);
GUILayout.Space(10);
CPUtility.DrawHeader("Define Symbols");
Expand All @@ -123,8 +93,6 @@ public static void OnDrawIap(Rect position)
CPUtility.DrawButtonAddDefineSymbols(ConstantDefineSymbols.VIRTUESKY_IAP);
#if VIRTUESKY_IAP
GUILayout.Space(10);
// Handles.DrawAAPolyLine(3, new Vector3(210, GUILayoutUtility.GetLastRect().y + 10),
// new Vector3(position.width, GUILayoutUtility.GetLastRect().y + 10));
CPUtility.GuiLine(2);
GUILayout.Space(10);
GUILayout.Label("Ping Iap Settings", EditorStyles.boldLabel);
Expand Down
2 changes: 1 addition & 1 deletion VirtueSky/ControlPanel/ConstantPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class ConstantPackage
{
public const string VersionSunflower = "3.2.1";
public const string VersionSunflower = "3.2.2";
public const string PackageNameInAppPurchase = "com.unity.purchasing";
public const string MaxVersionInAppPurchase = "4.12.2";
public const string PackageNameNewtonsoftJson = "com.unity.nuget.newtonsoft-json";
Expand Down
15 changes: 1 addition & 14 deletions VirtueSky/Iap/Editor/IapSettingEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,16 @@ public override void OnInspectorGUI()
serializedObject.ApplyModifiedProperties();
}

private string path = CreateAsset.DefaultPath("/Iap/Products");

void GenerateProduct()
{
_iapSetting.Products.Clear();
for (int i = 0; i < _iapSetting.SkusData.Count; i++)
{
string itemName = _iapSetting.SkusData[i].id.Split('.').Last();
// Debug.Log(itemName);
AssetDatabase.DeleteAsset($"{path}/iap_{itemName.ToLower()}.asset");
var itemDataVariable = CreateInstance<IapDataVariable>();
var itemDataVariable = CreateAsset.CreateAndGetScriptableAssetByName<IapDataVariable>("/Iap/Products", $"iap_{itemName.ToLower()}");
itemDataVariable.id = _iapSetting.SkusData[i].id;
itemDataVariable.productType = _iapSetting.SkusData[i].productType;
itemDataVariable.eventPurchaseProduct = CreateAsset.CreateAndGetScriptableAsset<VirtueSky.Iap.EventPurchaseProduct>("/Iap",
"iap_purchase_product_event");
itemDataVariable.eventIsPurchaseProduct = CreateAsset.CreateAndGetScriptableAsset<VirtueSky.Iap.EventIsPurchaseProduct>("/Iap",
"iap_is_purchase_product_event");
_iapSetting.Products.Add(itemDataVariable);
AssetDatabase.CreateAsset(itemDataVariable, $"{path}/iap_{itemName.ToLower()}.asset");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

// Selection.activeObject = itemDataVariable;
}

serializedObject.ApplyModifiedProperties();
Expand Down
93 changes: 0 additions & 93 deletions VirtueSky/Iap/Editor/IapWindowEditor.cs

This file was deleted.

3 changes: 0 additions & 3 deletions VirtueSky/Iap/Editor/IapWindowEditor.cs.meta

This file was deleted.

3 changes: 0 additions & 3 deletions VirtueSky/Iap/Runtime/Event.meta

This file was deleted.

Binary file removed VirtueSky/Iap/Runtime/Event/.DS_Store
Binary file not shown.
12 changes: 0 additions & 12 deletions VirtueSky/Iap/Runtime/Event/EventIapProductListener.cs

This file was deleted.

11 changes: 0 additions & 11 deletions VirtueSky/Iap/Runtime/Event/EventIapProductListener.cs.meta

This file was deleted.

15 changes: 0 additions & 15 deletions VirtueSky/Iap/Runtime/Event/EventIsPurchaseProduct.cs

This file was deleted.

11 changes: 0 additions & 11 deletions VirtueSky/Iap/Runtime/Event/EventIsPurchaseProduct.cs.meta

This file was deleted.

14 changes: 0 additions & 14 deletions VirtueSky/Iap/Runtime/Event/EventPurchaseProduct.cs

This file was deleted.

11 changes: 0 additions & 11 deletions VirtueSky/Iap/Runtime/Event/EventPurchaseProduct.cs.meta

This file was deleted.

13 changes: 9 additions & 4 deletions VirtueSky/Iap/Runtime/IapDataVariable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public class IapDataVariable : ScriptableObject
{
[ReadOnly] public string id;
[ReadOnly] public ProductType productType;
[ReadOnly] public EventPurchaseProduct eventPurchaseProduct;
[ReadOnly] public EventIsPurchaseProduct eventIsPurchaseProduct;

[Space] public float price;
[SerializeField] private IapPurchaseSuccess onPurchaseSuccess;
Expand All @@ -30,14 +28,21 @@ public class IapDataVariable : ScriptableObject
public Product Product => product;
public SubscriptionInfo SubscriptionInfo => subscriptionInfo;

private IapManager iapManager;

internal void InitIapManager(IapManager _iapManager)
{
iapManager = _iapManager;
}

public void Purchase()
{
eventPurchaseProduct.Raise(this);
iapManager.PurchaseProduct(this);
}

public bool IsPurchased()
{
return eventIsPurchaseProduct.Raise(this);
return iapManager.IsPurchasedProduct(this);
}
}
}
Expand Down
Loading

0 comments on commit 66f70be

Please sign in to comment.