/// <summary> /// Removes all scripts related to specifeid MVC view. /// </summary> public static void RemoveScripts(MvcConfig.View view) { // Delete base autogen file string autoGenFile = MvcViewAutoGen.GetBaseScriptPath( MvcWorkspace.AutogenCodePath, view.Name ); if (File.Exists(autoGenFile)) { File.Delete(autoGenFile); } else { RenLog.Log("MvcViewRemover.RemoveScripts - Base file missing: " + autoGenFile); } // Delete the folder string directory = MvcViewAutoGen.GetDirectoryPath( MvcWorkspace.WorkspacePath, view.Name ); if (Directory.Exists(directory)) { Directory.Delete(directory, true); } else { RenLog.Log("MvcViewRemover.RemoveScripts - Scripts directory missing: " + directory); } // Refresh the project view AssetDatabase.Refresh(); }
/// <summary> /// Method for outputting debug messages. /// </summary> public static void LogMessage(object message) { if (IAP.DebugMessage) { RenLog.Log(LogLevel.Info, message); } }
/// <summary> /// Copies the contents of this object to specified array from index. /// </summary> public void CopyTo(KeyValuePair <string, JsonData>[] array, int arrayIndex) { if (array == null) { RenLog.Log(LogLevel.Warning, "JsonObject.CopyTo - Parameter 'array' can't be null!"); return; } int loopCount = Mathf.Clamp( objectData.Count, 0, Mathf.Min(objectData.Count, array.Length - arrayIndex) ); int looped = 0; foreach (var pair in objectData) { //Set reference array[looped + arrayIndex] = pair; //Change index looped++; if (looped >= loopCount) { break; } } }
/// <summary> /// Resets the specified item to its re-usable state. /// </summary> public virtual void Reset(T item) { if (item == null) { RenLog.Log(LogLevel.Warning, "BaseRecycler.Reset - Parameter 'item' can't be null!"); return; } FireOnReset(item); }
/// <summary> /// Returns whether the specified item is valid (active). /// </summary> public virtual bool IsItemValid(T item) { if (item == null) { RenLog.Log(LogLevel.Warning, "BaseRecycler.IsItemActive - Parameter 'item' can't be null!"); return(true); } return(FireOnCheckValid(item)); }
/// <summary> /// Specifies which crypto method to use. /// </summary> public static void SetCryptoMethod(ICrypto crypto) { if (crypto == null) { RenLog.Log(LogLevel.Warning, "SecurePrefs.SetCryptoMethod - Parameter 'crypto' may not be null!"); return; } Crypto = crypto; }
/// <summary> /// Creates a new Color with string values. /// Supported formats: /// #{rr}{gg}{bb}{aa} /// #{rr}{gg}{bb} /// ** Cases are non-sensitive. /// ** Hashtag (#) not required. /// </summary> public static Color Create(string str) { int r = 255, g = 255, b = 255, a = 255; if (str[0] == '#') { str = str.Substring(1); } switch (str.Length) { case 3: { r = ParseHex(str[0]) * 16 + ParseHex(str[0]); g = ParseHex(str[1]) * 16 + ParseHex(str[1]); b = ParseHex(str[2]) * 16 + ParseHex(str[2]); break; } case 4: { r = ParseHex(str[0]) * 16 + ParseHex(str[0]); g = ParseHex(str[1]) * 16 + ParseHex(str[1]); b = ParseHex(str[2]) * 16 + ParseHex(str[2]); a = ParseHex(str[3]) * 16 + ParseHex(str[3]); break; } case 6: { r = ParseHex(str[0]) * 16 + ParseHex(str[1]); g = ParseHex(str[2]) * 16 + ParseHex(str[3]); b = ParseHex(str[4]) * 16 + ParseHex(str[5]); break; } case 8: { r = ParseHex(str[0]) * 16 + ParseHex(str[1]); g = ParseHex(str[2]) * 16 + ParseHex(str[3]); b = ParseHex(str[4]) * 16 + ParseHex(str[5]); a = ParseHex(str[6]) * 16 + ParseHex(str[7]); break; } default: RenLog.Log(LogLevel.Warning, "HexColor.Create - Invalid string given: " + str); break; } return(new Color( r * ByteReciprocal, g * ByteReciprocal, b * ByteReciprocal, a * ByteReciprocal )); }
/// <summary> /// Opens the native gallery for an image and returns its path to the specified callback. /// </summary> public static void PickImage(CropOption cropOption, ImageResultHandler callback) { if (I == null) { RenLog.Log(LogLevel.Warning, "GalleryPicker.PickImage - You must initialize this module first!"); return; } I.onImageResult = callback; I.galleryPlugin.PickImage(cropOption); }
/// <summary> /// Destroys (disposes) the specified item for removal. /// Returns whether it's a success or failure. /// </summary> public virtual bool Destroy(T item) { if (item == null) { RenLog.Log(LogLevel.Warning, "BaseRecycler.Destroy - Parameter 'item' can't be null!"); return(false); } FireOnDestroy(item); return(true); }
/// <summary> /// Opens the native gallery for a video and returns its path to the specified callback. /// </summary> public static void PickVideo(VideoResultHandler callback) { if (I == null) { RenLog.Log(LogLevel.Warning, "GalleryPicker.PickVideo - You must initialize this module first!"); return; } I.onVideoResult = callback; I.galleryPlugin.PickVideo(); }
/// <summary> /// Checks for any request error. /// </summary> public void CheckError() { //Timeout error if (IsTimeOut) { SetError("The request has timed out."); RenLog.Log( "NetkoRequest.CheckError - Timeout error at url: {1}" + Url ); } }
/// <summary> /// Starts the task and returns this instance. /// May return null if this task was already invoked once. /// </summary> public Task Start() { if (alreadyStarted) { RenLog.Log(LogLevel.Warning, "Tentacle.Task.Start - A task can't be called more than once on the same instance!"); return(null); } alreadyStarted = true; workerThread.Start(); return(this); }
/// <summary> /// Loads the config file from resources and returns it. /// </summary> public static MvcConfig LoadFromResources() { TextAsset file = ResourceLoader.LoadTextAsset( MvcResources.GetConfigFilePath(false) ); if (file == null) { RenLog.Log(LogLevel.Info, "MvcConfig.LoadFromResources - Text asset not found. Returning default configuration."); return(DefaultConfig); } return(new MvcConfig(file.text)); }
void ShowInitialView() { if (!EditorApplication.isPlaying) { return; } if (firstViewType == null) { RenLog.Log(LogLevel.Warning, "MVC.ShowInitialView - The initial view type is not defined."); return; } ShowView(firstViewType); }
/// <summary> /// Adds the specified item. /// If null, the OnCreateHandler event will be fired. /// Returns the added item. /// </summary> public virtual T Add(T item = null) { if (item == null) { item = FireOnCreate(); } if (item == null) { RenLog.Log(LogLevel.Warning, "BaseRecycler.Add - OnCreateHandler and the specified item is null!"); return(null); } items.Add(item); return(item); }
public void Initialize(string objectName) { #if UNITY_EDITOR try { pickerObject = GameObject.FindObjectOfType <GalleryPicker>().gameObject; } catch (Exception e) { RenLog.Log( LogLevel.Warning, "EditorGallery.Initialize - GalleryPicker instance is not found in scene!\n" + e.Message ); } #endif }
/// <summary> /// Adds the given key and value if key doesn't already exist. /// Returns true if successfully added. /// </summary> private bool AddIfNotExists(string key, JsonData value) { if (key == null) { RenLog.Log(LogLevel.Warning, "JsonObject.AddIfNotExists - Parameter 'key' can't be null."); return(false); } if (objectData.ContainsKey(key)) { return(false); } objectData.Add(key, GetNullSafeData(value)); return(true); }
/// <summary> /// The key used for encryption / decryption. /// </summary> public void SetKey(string key) { if (string.IsNullOrEmpty(key)) { RenLog.Log(LogLevel.Warning, "CryptoAES.SetKey - Key can't be null or empty."); return; } if (key.Length != 16) { RenLog.Log(LogLevel.Warning, "CryptoAES.SetKey - Key length must be 16."); return; } passByte = Encoding.UTF8.GetBytes(key); }
/// <summary> /// Fires the OnCreate handler and returns new item. /// </summary> protected override T FireOnCreate() { T item = base.FireOnCreate(); if (item != null) { return(item); } //Prefab and its component (T) should exist. if (Prefab == null || Prefab.GetComponent <T>() == null) { RenLog.Log(LogLevel.Warning, "UnityRecycler.FireOnCreate - Prefab must contain the corresponding component."); return(null); } return(GameObject.Instantiate(Prefab, Parent).GetComponent <T>()); }
/// <summary> /// Removes the view prefab linked to specified view config from resources. /// </summary> public static void RemovePrefab(MvcConfig.View view) { string prefabPath = view.GetResourcePath(true, true); if (File.Exists(prefabPath)) { File.Delete(prefabPath); } else { RenLog.Log("MvcViewRemover.RemoveScripts - Prefab file missing: " + prefabPath); } // Refresh the project view AssetDatabase.Refresh(); }
/// <summary> /// Returns whether specified json data is safe, according to checks filtered with options. /// </summary> public static bool IsJsonSafe(JsonData data, JsonSerializeOptions options) { // No checks required. if (options.IgnoreSafetyChecks) { return(true); } // Circular reference check. if (!options.IgnoreCircularReference && IsCircularReference(data)) { RenLog.Log(LogLevel.Error, "JsonSerializeSafety.IsJsonSafe - Failed to pass circular reference check."); return(false); } // Everything looks good return(true); }
/// <summary> /// Takes a new photo and saves at specified file path. /// On iOS, the photo will be saved to the library along with documents directory, /// as you can't directly access files in the photo library. /// </summary> public static void TakePhoto(SaveOption saveOptions, CropOption cropOptions, PhotoResultHandler callback) { if (I == null) { RenLog.Log(LogLevel.Warning, "NativeCamera.TakePhoto - You must initialize this module first!"); return; } if (saveOptions == null) { saveOptions = new SaveOption(); } if (cropOptions == null) { cropOptions = new CropOption(); } I.onPhotoResult = callback; I.camPlugin.TakePhoto(saveOptions, cropOptions); }
/// <summary> /// Gets or sets data at specified index. /// This property returns null JsonData if index is out of range. /// This property will automatically resize the array if index >= item count. /// </summary> public JsonData this[int index] { get { if (index >= listData.Count || index < 0) { return(new JsonData(null)); } return(listData[index]); } set { if (index < 0) { RenLog.Log(LogLevel.Warning, "JsonArray.this[] - Index can't be less than 0."); return; } //Add dummy items to avoid index out of range exception AddDummy(index + 1 - listData.Count); listData[index] = GetNullSafeData(value); } }
public string FinalizePhoto(string filePath) { // If the photo is saved in persistent datapath and image should be cropped, // We must get rid of the original image before cropping. if (lastSaveOption != null && lastCropOption != null && !lastSaveOption.SaveToLibrary && lastCropOption.IsCropping) { string originalPath = string.Format( "{0}/{1}.jpg", Application.persistentDataPath, lastSaveOption.FileName ); if (File.Exists(originalPath)) { RenLog.Log(LogLevel.Info, "AndroidCamera.FinalizePhoto - Removing original photo: " + originalPath); File.Delete(originalPath); } } return(filePath); }
public T this[int index] { get { if (index < 0 || index >= items.Count) { throw new IndexOutOfRangeException(); } return(items[index]); } set { if (index < 0 || index >= items.Count) { throw new IndexOutOfRangeException(); } if (value == null) { RenLog.Log(LogLevel.Warning, "BaseRecycler.this - value can't be null!"); return; } items[index] = value; } }
/// <summary> /// Deserializes the specified JsonData for a specific type. /// Highly recommended to use Json.Parse with Type parameter instead. /// </summary> public static object Deserialize(Type t, object instance, JsonObject data) { object adaptorResult = JsonAdaptor.Deserialize(t, data); if (adaptorResult != null) { return(adaptorResult); } //IJsonable method requires an instance to be present. if (instance == null) { instance = DynamicService.CreateObject(t); if (instance == null) { RenLog.Log(LogLevel.Error, string.Format( "JsonDeserializer.Deserialize - Failed to instantiate a dynamic object of type ({0}). If possible, try adding a parameterless constructor.", t.Name )); return(null); } } IJsonable jsonable = instance as IJsonable; if (jsonable != null) { jsonable.FromJsonObject(data); return(instance); } //No deserializer is available. RenLog.Log(LogLevel.Warning, string.Format( "JsonDeserializer.Deserialize - There is no deserializer available for type ({0}). Returning null." )); return(null); }
/// <summary> /// Finalizes the awake process. /// </summary> void FinalizeAwake() { // No initialization, no MVC if (!isCoreInitialized) { RenLog.Log(LogLevel.Error, "MVC.FinalizeAwake - Core MVC components are not initialized!"); Destroy(gameObject); return; } // View parent is not set. // If user really wants to MVC without the parent, ShowView should be called manually. if (ViewParent == null) { RenLog.LogWarning("MVC.FinalizeAwake - ViewParent property is null! " + "Call MVC.ShowView after setting the property."); return; } // Show first view, then we're finished :D if (InitialViewOnAwake && firstViewType != null) { ShowView(firstViewType); } }
/// <summary> /// Returns a new object of specified type. /// May return null if the type doesn't contain a parameterless constructor. /// </summary> public static object CreateObject(Type t) { if (t == null) { return(null); } //Some primitive types that may need manual instantiation. if (t == typeof(String)) { return(""); } try { return(Activator.CreateInstance(t)); } catch (Exception e) { RenLog.Log(LogLevel.Error, string.Format( "DynamicService.CreateObject - Could not instantiate type: {0}\n{1}\n{2}", t.FullName, e.Message, e.StackTrace )); return(null); } }
/// <summary> /// Displays the validation result via console log. /// </summary> public static void DisplayLog(ValidationResult result) { RenLog.Log(LogLevel.Warning, result.ToString() + " - " + ParseMessage(result)); }
/// <summary> /// The key used for encryption / decryption. /// </summary> public void SetKey(string key) { RenLog.Log(LogLevel.Info, "CryptoNone.SetKey - Key: " + key); }