static void Init() { isUsingOnClanSDK = System.Type.GetType("OnClanSDKHandler,Assembly-CSharp") != null; //isUsingAppotaSDK = System.Type.GetType("AppotaSDKHandler,Assembly-CSharp") != null; windows = GetWindow(typeof(IDController), false, "Appota", true) as IDController; windows.minSize = new Vector2(400, 550); windows.maxSize = new Vector2(600, 700); windows.Show(); EditorWindow.GetWindow(typeof(IDController)).Show(); _facebookID = AppotaSetting.FacebookAppID; _facebookSecretID = AppotaSetting.FacebookAppSecretID; _facebookAppLinkUrl = AppotaSetting.FacebookAppLinkUrl; _twitterKey = AppotaSetting.TwitterConsumerKey; _twitterSecret = AppotaSetting.TwitterConsumerSecret; _googleID = AppotaSetting.GoogleClientId; _googleSecretID = AppotaSetting.GoogleClientSecretId; _gameID = AppotaSetting.GameID; _inAppApiKey = AppotaSetting.InAppApiKey; _usingAppFlyer = AppotaSetting.UsingAppFlyer; _appleAppID = AppotaSetting.AppleAppID; _appFlyerKey = AppotaSetting.AppFlyerKey; _usingAdWords = AppotaSetting.UsingAdWords; _adWordsConversionID = AppotaSetting.AdWordsConversionID; _adWordsLabel = AppotaSetting.AdWordsLabel; _adWordsValue = AppotaSetting.AdWordsValue; _adWordsIsRepeatable = AppotaSetting.AdWordsIsRepeatable; }
/// <summary> /// Generate a mapping of all scriptMappings in a project. /// Which means it creates a mapping between versions. /// </summary> /// <param name="oldIDsPath"></param> /// <param name="newIDsPath"></param> /// <returns></returns> public void MapAllClasses(string oldIDsPath, string newIDsPath) { List <ClassModel> oldIDs = IDController.DeserializeIDs(oldIDsPath); List <ClassModel> newIDs = IDController.DeserializeIDs(newIDsPath); MapAllClasses(oldIDs, newIDs); }
static void Init() { isUsingOnClanSDK = System.Type.GetType("OnClanSDKHandler,Assembly-CSharp") != null; //isUsingGMOSDK = System.Type.GetType("GMOSDKHandler,Assembly-CSharp") != null; windows = GetWindow(typeof (IDController), false, "GMO", true) as IDController; windows.minSize = new Vector2(400, 400); windows.maxSize = new Vector2(600, 600); windows.Show(); EditorWindow.GetWindow(typeof (IDController)).Show(); _facebookID = GMOSetting.FacebookAppID; _facebookSecretID = GMOSetting.FacebookAppSecretID; _facebookAppLinkUrl = GMOSetting.FacebookAppLinkUrl; _twitterKey = GMOSetting.TwitterConsumerKey; _twitterSecret = GMOSetting.TwitterConsumerSecret; _googleID = GMOSetting.GoogleClientId; _googleSecretID = GMOSetting.GoogleClientSecretId; _gameID = GMOSetting.GameID; _inAppApiKey = GMOSetting.InAppApiKey; _usingAppFlyer = GMOSetting.UsingAppFlyer; _appleAppID = GMOSetting.AppleAppID; _appFlyerKey = GMOSetting.AppFlyerKey; _usingAdWords = GMOSetting.UsingAdWords; _adWordsConversionID = GMOSetting.AdWordsConversionID; _adWordsLabel = GMOSetting.AdWordsLabel; _adWordsValue = GMOSetting.AdWordsValue; _adWordsIsRepeatable = GMOSetting.AdWordsIsRepeatable; }
public Vehicle(ManufacturersForTransmissionsAndVehicles manufacturer, Engine engine, Chassis chassis, Transmission transmission) { Id = IDController.GetId(); Manufacturer = manufacturer; VehicleEngine = engine; VehicleChassis = chassis; VehicleTransmission = transmission; }
public async Task TestSetGetWatchdogsAsync() { string transactionHash = await IDController.SetWatchDogsAsync(AddressFrom, Watchdogs.GetAddress(), new HexBigInteger(3905820)); Assert.NotNull(transactionHash); string watchdogsAddress = await IDController.GetWatchDogsAsyncCall(); Assert.AreEqual(Watchdogs.GetAddress(), watchdogsAddress); }
public async override Task TestAddGetOwnedAttributeAsync() { byte[] key = Byte32Encoder.Encode("key"); string transactionHash = await IDController.AddAttributeAsync(AddressFrom, key, OwnedAttribute.GetAddress(), new HexBigInteger(3905820)); Assert.NotNull(transactionHash); string attributeAddress = await IDController.GetAttributeAsyncCall(key); Assert.NotNull(attributeAddress); Assert.AreEqual(OwnedAttribute.GetAddress(), attributeAddress); }
public async override Task TestChangeOwner() { string newOwner = "0x0000000000000000000000000000000000000000"; string ownerAddress = await IDController.OwnerAsyncCall(); Assert.AreEqual(AddressFrom, ownerAddress); string transactionHash = await IDController.ChangeOwnerAsync(AddressFrom, newOwner, new HexBigInteger(3905820)); ownerAddress = await IDController.OwnerAsyncCall(); Assert.AreEqual(newOwner, ownerAddress); }
public async override Task TestRemoveAttributeAsync() { //Add the attribute to the contract, and get it await TestAddGetOwnedAttributeAsync(); //Remove the attribute byte[] key = Byte32Encoder.Encode("key"); string tansactionHash = await IDController.RemoveAttributeAsync(AddressFrom, key, new HexBigInteger(3905820)); string attributeAddress = await IDController.GetAttributeAsyncCall(key); Assert.AreEqual("0x0000000000000000000000000000000000000000", attributeAddress); }
public async Task TestProposeAndGetDeletion() { string transactionHash = await Watchdogs.ProposeDeletionAsync(AddressFrom, IDController.GetAddress(), new HexBigInteger(3905820)); Assert.NotNull(transactionHash); GetProposalDTO proposal = await Watchdogs.GetProposalAsyncCall(); //test for call destination Assert.AreEqual(IDController.GetAddress(), proposal.A); //test for the new proposed owner Assert.AreEqual("0x0000000000000000000000000000000000000000", proposal.B); //test for the initiator of the proposal Assert.AreEqual(AddressFrom, proposal.C); //TODO: test for proposal hash by parsing the event //TODO: check that the user has automatically confirmed the proposal }
/// <summary> /// Transforms the prefabs. /// Only changes the guid's and fileIDs as the fields and classes should be exactly the same /// </summary> /// <param name="oldIDs"></param> /// <param name="newIDs"></param> /// <param name="originalProjectPath"></param> /// <param name="destinationProjectPath"></param> public static void TransformIDsOfPrefabs(List <ClassModel> oldIDs, List <ClassModel> newIDs, string originalProjectPath, string destinationProjectPath) { List <PrefabModel> exportPrefabs = new PrefabController().ExportPrefabs(originalProjectPath); List <ScriptMapping> scriptMappings = new List <ScriptMapping>(); IDController idController = new IDController(); PrefabView prefabView = new PrefabView(); foreach (PrefabModel prefab in exportPrefabs) { string[] parsedPrefab = idController.TransformIDs(prefab.Path, oldIDs, newIDs, ref scriptMappings); prefabView.SavePrefabFile(parsedPrefab, prefab, destinationProjectPath); } Debug.Log("Converted all prefabs to : " + destinationProjectPath); }
private async Task DeployWatchdogsAsync() { string transactionHash = await WatchdogService.DeployContractAsync( Web3, AddressFrom, new string[] { AddressFrom, AddressFrom2 }, new BigInteger(2), new HexBigInteger(3905820)); Assert.NotNull(transactionHash); TransactionReceipt receipt = await Web3.Eth.Transactions.GetTransactionReceipt. SendRequestAsync(transactionHash); Watchdogs = new WatchdogService(Web3, receipt.ContractAddress); transactionHash = await IDController.SetWatchDogsAsync(AddressFrom, Watchdogs.GetAddress(), new HexBigInteger(3905820)); Assert.NotNull(transactionHash); }
/// <summary> /// Transforms the prefabs. /// Only changes the guid's and fileIDs as the fields and classes should be exactly the same /// </summary> /// <param name="originalExportFile"></param> /// <param name="destinationExportFile"></param> /// <param name="originalProjectPath"></param> /// <param name="destinationProjectPath"></param> /// <exception cref="FormatException"></exception> /// <exception cref="DirectoryNotFoundException"></exception> public static void TransformIDsOfPrefabs(string originalExportFile, string destinationExportFile, string originalProjectPath, string destinationProjectPath) { if ( !originalExportFile.EndsWith(".json") || !File.Exists(originalExportFile) || !destinationExportFile.EndsWith(".json") || !File.Exists(destinationExportFile) ) { throw new FormatException("Could not read exports files. Please check the Exports.json"); } if (!Directory.Exists(originalProjectPath) || !Directory.Exists(destinationProjectPath)) { throw new DirectoryNotFoundException("Could not find the original or destination path"); } List <ClassModel> oldIDs = IDController.DeserializeIDs(originalProjectPath); List <ClassModel> newIDs = IDController.DeserializeIDs(destinationExportFile); TransformIDsOfPrefabs(oldIDs, newIDs, originalProjectPath, destinationProjectPath); }
/// <summary> /// Parse the prefab. /// Change the guid's and fileID's on scripts and port the fields /// </summary> /// <param name="prefabFile"></param> /// <param name="originalAssetPath"></param> /// <param name="destinationAssetPath"></param> /// <param name="prefabs"></param> /// <param name="prefabGuid"></param> /// <exception cref="FormatException"></exception> /// <exception cref="NullReferenceException"></exception> public List <ScriptMapping> MigratePrefab(string prefabFile, string originalAssetPath, string destinationAssetPath, List <PrefabModel> prefabs, string prefabGuid, List <ScriptMapping> scriptMappings) { try { if (!prefabFile.EndsWith(".prefab")) { throw new FormatException("Could not parse prefab, not of type prefab, file : " + prefabFile); } Debug.Log("Started migration of prefab: " + prefabFile); if (BinaryUtility.IsBinaryFile(prefabFile)) { Debug.LogError("Could not parse file, since it's a binary file. Prefab file: " + prefabFile); return(scriptMappings); } PrefabModel currentPrefab = prefabs.FirstOrDefault(prefab => prefab.Guid == prefabGuid); if (currentPrefab == null) { Debug.LogError( "Could not find reference to the prefab with the guid. Might be a model file. Prefab: " + prefabFile); return(scriptMappings); } string originalProjectPath = ProjectPathUtility.getProjectPathFromFile(prefabFile); //Deserialize the old ID's List <ClassModel> oldIDs = Administration.Instance.oldIDsOverride ?? IDController.DeserializeIDs(originalProjectPath + constants.RelativeExportPath); if (oldIDs == null) { throw new NullReferenceException("Old IDs not set"); } //Deserialize the new ID's List <ClassModel> newIDs = Administration.Instance.newIDsOverride ?? IDController.DeserializeIDs(destinationAssetPath + constants.RelativeExportPath); if (newIDs == null) { throw new NullReferenceException("New IDs not set"); } string[] parsedPrefab = idController.TransformIDs(currentPrefab.Path, oldIDs, newIDs, ref scriptMappings); var unmappedScriptMappings = scriptMappings .Where(script => script.HasBeenMapped == ScriptMapping.MappedState.NotMapped).ToList(); if (unmappedScriptMappings.Count == 0) { parsedPrefab = fieldMappingController.MigrateFields(prefabFile, ref parsedPrefab, ref scriptMappings, originalAssetPath, destinationAssetPath); SavePrefabFile(parsedPrefab, currentPrefab, destinationAssetPath); } else { bool completed = false; ThreadUtility.RunMainTask(() => { MergeWizard wizard = MergeWizard.CreateWizard(unmappedScriptMappings); wizard.onComplete = mergedScriptMappings => { scriptMappings = scriptMappings.Merge(mergedScriptMappings); File.WriteAllText(destinationAssetPath + constants.RelativeScriptMappingPath, JsonConvert.SerializeObject(scriptMappings, constants.IndentJson)); ThreadUtility.RunTask(() => { parsedPrefab = fieldMappingController.MigrateFields(prefabFile, ref parsedPrefab, ref scriptMappings, originalAssetPath, destinationAssetPath); SavePrefabFile(parsedPrefab, currentPrefab, destinationAssetPath); }); completed = true; }; }); while (!completed) { Thread.Sleep(constants.THREAD_WAIT_TIME); } } } catch (Exception e) { Debug.LogError("Could not parse prefab: " + prefabFile + "\r\nException: " + e); } return(scriptMappings); }
/// <summary> /// Migrate a scene /// </summary> /// <param name="scenePath">The scene file to migrate</param> public void MigrateScene(string scenePath = null, string rootPath = null) { try { if (scenePath == null) { ThreadUtility.RunWaitMainTask(() => { scenePath = EditorUtility.OpenFilePanel("Scene to import", constants.RootDirectory, "unity"); }); if (scenePath.Length == 0) { Debug.LogWarning("No path was selected"); return; } } if (rootPath == null) { rootPath = constants.RootDirectory; } Debug.Log("Started migration of scene: " + scenePath); if (BinaryUtility.IsBinaryFile(scenePath)) { Debug.LogError("Could not parse file, since it's a binary file. Scene file: " + scenePath); return; } string IDPath = ProjectPathUtility.getProjectPathFromFile(scenePath) + constants.RelativeExportPath; if (!File.Exists(IDPath)) { ThreadUtility.RunWaitMainTask(() => { EditorUtility.DisplayDialog("Could not find old ID's", "Could not find the ID's of the original project. File does not exist : \r\n" + IDPath, "Ok"); }); return; } List <ClassModel> oldIDs = Administration.Instance.oldIDsOverride ?? IDController.DeserializeIDs(IDPath); string newIDsPath = rootPath + constants.RelativeExportPath; List <ClassModel> newIDs; if (Administration.Instance.newIDsOverride == null) { newIDs = File.Exists(newIDsPath) ? IDController.DeserializeIDs(newIDsPath) : idController.ExportClassData(rootPath); } else { newIDs = Administration.Instance.newIDsOverride; } List <ScriptMapping> scriptMappings = new List <ScriptMapping>(); string scriptMappingsPath = rootPath + constants.RelativeScriptMappingPath; if (Administration.Instance.ScriptMappingsOverride != null) { scriptMappings = Administration.Instance.ScriptMappingsOverride; } else if (File.Exists(scriptMappingsPath)) { scriptMappings = MappingController.DeserializeMapping(scriptMappingsPath); } this.MigrateSceneIDs(rootPath, oldIDs, newIDs, scenePath, scriptMappings); Debug.Log("Migrated scene : " + scenePath); } catch (Exception e) { Debug.LogError("Could not migrate scene: " + scenePath + "\r\nException: " + e); } }
public async Task TestGetIDAsync() { string IDAddress = await IDController.GetIDAsyncCall(); Assert.AreEqual(ID.GetAddress(), IDAddress); }
/// <summary> /// Load custom IDs as old IDs /// </summary> private void LoadCustomIDs() { Administration.Instance.oldIDsOverride = IDController.DeserializeIDs(customOldIDSPath); }