private static int GetMaterialRawRQFromShader(Material m) { MethodInfo methodInfo = getGetMaterailRawRQMethod(); System.Object result = methodInfo.Invoke(null, new[] { m }); return((int)result); }
public static T GetReflectedFieldRecursively <T>(SerializedProperty prop, string fieldName = "") { System.Object targetObject = null; FieldInfo info = GetReflectedFieldInfoRecursively(prop, out targetObject, fieldName); T temp = default(T); try { temp = (T)(info.GetValue(targetObject)); } catch { try { try { temp = (T)(info.GetValue(targetObject) as IList)[int.Parse(prop.propertyPath.Substring(prop.propertyPath.LastIndexOf("data[") + 5).Split(']')[0])]; } catch { temp = (T)((System.Object[])info.GetValue(targetObject))[int.Parse(prop.propertyPath.Substring(prop.propertyPath.LastIndexOf("data[") + 5).Split(']')[0])]; } } catch { // Debug.LogWarning(string.Format("The script has no property named {0}.", prop.name)); } } return(temp); }
public static void CreateCharacterAsset(string name, CCACallback callback, System.Object param, bool pack = true) { if (callback == null) { return; } if (string.IsNullOrEmpty(name)) { return; } CharacterAsset ca = null; int index = -1; if (strToID.TryGetValue(name, out index)) { if (index >= 0) { assetArr.TryGetValue(index, out ca); if (ca != null) { if (callback != null) { callback(ca, param); } return; } } } ResLoader.LoadByName(name, OnLoad, new LoadInfo() { name = name, callback = callback, param = param, pack = pack }, true); }
public static void PrintObjectInfo(System.Object pObject) { System.Type type = pObject.GetType(); Debug.Log("PrintObjectInfo " + type.Name); //Debug.Log("lenght = " + type.GetMembers().Length); Debug.Log("lenght = " + type.GetFields().Length); System.Reflection.FieldInfo[] fields = type.GetFields(); string tempvalue = ""; foreach (System.Reflection.FieldInfo field in fields) { if (field.FieldType.IsArray) { tempvalue += field.Name + " = ["; Array array = (Array)field.GetValue(pObject); foreach (System.Object obj in array) { tempvalue += obj.ToString() + ","; } tempvalue += " ]\n"; } else { tempvalue += field.Name + " = " + field.GetValue(pObject) + "\n"; //Debug.Log("Name:" + field.Name + " Value:" + field.GetValue(pObject));// field.Name, field.ToString()) } } Debug.Log(tempvalue); }
int IComparer.Compare(System.Object xo, System.Object yo) { int x = ((AssetPostprocessor)xo).GetPostprocessOrder(); int y = ((AssetPostprocessor)yo).GetPostprocessOrder(); return(x.CompareTo(y)); }
public static void SendMessage(GameEvent gameEvent, System.Object sender) { if (Instance != null) { Instance.SendMessage(gameEvent); } }
private void ApplyProperty(object newValue) { m_MixedValueMask = 0; object previousValue = m_Value; m_Value = newValue; ApplyProperty(previousValue, 1); }
public static void InvokeExceptionSafe(this System.Object obj, string methodName, params object[] args) { try { obj.Invoke(methodName, args); } catch (System.Exception ex) { Debug.LogException(ex); } }
public PropertyData(System.Object instance, PropertyInfo info) : base(instance, info) { inspectorType = GetInspectorType(info.PropertyType); _getMethodInfo = _info.GetGetMethod(); _setMethodInfo = _info.GetSetMethod(); }
public override void SetValue(System.Object value) { if ((_setMethodInfo == null)) { return; } _setMethodInfo.Invoke(instance, new System.Object[] { value }); }
static FieldInfo GetReflectedFieldInfoRecursively(System.Object targetObject, FieldInfo field, string propName, List <string> pathNames, out System.Object outObject) { if (pathNames.Count > 1 && pathNames[0] != propName) { pathNames.RemoveAt(0); if (pathNames[0].Contains("data[")) { // The next field is hidden inside a list int pathIndex = int.Parse(pathNames[0].Replace("data[", "").Replace("]", "")); pathNames.RemoveAt(0); try { try { // If index is greater than length, the list's size is being increased this frame, return null to prevent an error and try again next frame. if ((field.GetValue(targetObject) as IList).Count <= pathIndex) { outObject = null; return(null); } } catch { if (((System.Object[])field.GetValue(targetObject)).Length <= pathIndex) { outObject = null; return(null); } } } catch { // If it breaks here, the value is null. Return for this frame to prevent an error and try again next frame. outObject = null; return(null); } try { return(GetReflectedFieldInfoRecursively((field.GetValue(targetObject) as IList)[pathIndex], field.FieldType.GetGenericArguments()[0].GetField(pathNames[0], BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public), propName, pathNames, out outObject)); } catch { return(GetReflectedFieldInfoRecursively(((System.Object[])field.GetValue(targetObject))[pathIndex], field.FieldType.GetElementType().GetField(pathNames[0], BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public), propName, pathNames, out outObject)); } } return(GetReflectedFieldInfoRecursively(field.GetValue(targetObject), field.FieldType.GetField(pathNames[0], BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public), propName, pathNames, out outObject)); } else { outObject = targetObject; return(field); } }
public static void Invoke(this System.Object obj, string methodName, params object[] args) { var method = obj.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); if (method != null) { method.Invoke(obj, args); } }
public PropertyField(System.Object instance, PropertyInfo info, SerializedPropertyType type) { m_Instance = instance; m_Info = info; m_Type = type; m_Getter = m_Info.GetGetMethod(); m_Setter = m_Info.GetSetMethod(); }
public System.Object SetObjectData(System.Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { var resourcePath = info.GetString("RP"); var result = Core.Instance.m_SerializationManager.Require(resourcePath); result?.iDeserialize(info); return(result); }
public void GetObjectData(System.Object obj, SerializationInfo info, StreamingContext context) { var loadableResource = (obj as ILoadableResource); info.AddValue("RP", loadableResource.iGetResourcePath()); loadableResource.iSerialize(info); info.SetType(typeof(WRITE_DATA)); }
private void LoadTex(AssetBundleRequest abr, System.Object param) { if (abr == null) { return; } textures = abr.asset as StringContentHolder; ResLoader.HelpLoadAsset(assetBundle, "rendererobject", LoadCallback, null, typeof(GameObject)); }
static void SetReflectedFieldRecursively <T>(System.Object targetObject, FieldInfo field, string propName, List <string> pathNames, T value, string fullName) where T : class { if (pathNames.Count >= 1 && pathNames[0] != propName) { pathNames.RemoveAt(0); if (pathNames[0].Contains("data[")) { // The next field is hidden inside a list int pathIndex = int.Parse(pathNames[0].Replace("data[", "").Replace("]", "")); pathNames.RemoveAt(0); try { SetReflectedFieldRecursively((field.GetValue(targetObject) as IList)[pathIndex], field.FieldType.GetGenericArguments()[0].GetField(pathNames[0], BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public), propName, pathNames, value, fullName); } catch { SetReflectedFieldRecursively(((System.Object[])field.GetValue(targetObject))[pathIndex], field.FieldType.GetElementType().GetField(pathNames[0], BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public), propName, pathNames, value, fullName); } } SetReflectedFieldRecursively(field.GetValue(targetObject), field.FieldType.GetField(pathNames[0], BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public), propName, pathNames, value, fullName); } else { try { field.SetValue(targetObject, value); } catch { try { if (field != null) { try { (field.GetValue(targetObject) as IList)[int.Parse(fullName.Substring(fullName.LastIndexOf("data[") + 5).Split(']')[0])] = value; } catch { ((System.Object[])field.GetValue(targetObject))[int.Parse(fullName.Substring(fullName.LastIndexOf("data[") + 5).Split(']')[0])] = value; } } } catch { //Debug.LogWarning(string.Format("The script has no property named {0}.", propName)); } } } }
public static string getMembersOf(System.Object t) { Type obj = t.GetType(); string log = "MEMBERS OF : " + obj.Name; MemberInfo[] member_info = obj.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (MemberInfo member in member_info) { log += "\nMember :" + member.Name; } return(log); }
private void OnObjectBuilt(System.Object sender, EventArgs eventArgs) { var varwinObject = (VarwinObjectDescriptor)target; ObjectsBuilderWindow window = GetWindow(); if (window != null) { window.ObjectBuilt -= OnObjectBuilt; } CreateObjectUtils.RevertPrefabInstanceChanges(varwinObject.gameObject); }
private static System.Object CreateInstance(Type type) { System.Object obj = null; try { obj = Activator.CreateInstance(type); } catch (Exception e) { Console.WriteLine(e); throw; } return(obj); }
private void LoadBone(AssetBundleRequest abr, System.Object param) { if (abr == null) { return; } boneName = abr.asset as StringContentHolder; if (pack) { ResLoader.HelpLoadAsset(assetBundle, "textures", LoadTex, null, typeof(StringContentHolder)); } else { ResLoader.HelpLoadAsset(assetBundle, "rendererobject", LoadCallback, null, typeof(GameObject)); } }
int IComparer.Compare(System.Object objX, System.Object objY) { AnimationEvent x = (AnimationEvent)objX; AnimationEvent y = (AnimationEvent)objY; float timeX = x.time; float timeY = y.time; if (timeX != timeY) { return((int)Mathf.Sign(timeX - timeY)); } int valueX = x.GetHashCode(); int valueY = y.GetHashCode(); return(valueX - valueY); }
public string GetText() { System.Object obj = null; if (!CacheTable.TryGetValue(ASSETTEXT, out obj)) { obj = www.downloadHandler.text; CacheTable.Add(ASSETTEXT, obj); } if (obj != null) { return(obj.ToString()); } else { return(string.Empty); } }
/// <summary> If it's in editor, get Game View size through reflection </summary> /// <returns></returns> public static Vector2 GetGameViewSize( ) { if (!Application.isEditor) { return(new Vector2(Screen.width, Screen.height)); } Type gameView = Type.GetType("UnityEditor.GameView,UnityEditor"); if (gameView == null) { return(Vector2.zero); } MethodInfo methodInfo = gameView.GetMethod("GetSizeOfMainGameView", BindingFlags.NonPublic | BindingFlags.Static); System.Object res = methodInfo.Invoke(null, null); return((Vector2)res); }
private void LoadCallback(AssetBundleRequest abr, System.Object param) { if (abr == null) { return; } goAsset = abr.asset; gameObject = (GameObject)Object.Instantiate(abr.asset); gameObject.SetActive(false); if (pack) { Renderer renderer = gameObject.GetComponent <Renderer>(); if (renderer != null) { Object.Destroy(renderer.material.mainTexture); } } Object.DontDestroyOnLoad(gameObject); }
public override bool Equals(System.Object obj) { // If parameter is null return false. if (obj == null) { return(false); } // If parameter cannot be cast to Point return false. var p = obj as DebugInfo; if ((System.Object)p == null) { return(false); } // Return true if the fields match: return((rating == p.rating) && (objectOfInfo == p.objectOfInfo) && (info == p.info) && (stack == p.stack)); }
private void OnPostprocessGameObjectWithUserProperties(GameObject go, string[] propNames, System.Object[] values) { Debug.Log("OnPostprocessGameObjectWithUserProperties"); for (int i = 0; i < propNames.Length; i++) { string propName = propNames[i]; System.Object value1 = values[i]; Debug.Log("GO: " + go.name + "--Propname: " + propName + "--value1: " + value1.GetType()); if (value1 is string) { Debug.Log("string: " + (string)value1); } if (value1 is Vector4) { Debug.Log("Vector4: " + (Vector4)value1); } if (value1 is Color) { Debug.Log("Color: " + (Color)value1); } if (value1 is bool) { Debug.Log("bool: " + (bool)value1); } if (value1 is int) { Debug.Log("int: " + (int)value1); } if (value1 is float) { Debug.Log("float: " + (float)value1); } } }
public static PropertyField[] GetProperties(System.Object obj) { List <PropertyField> fields = new List <PropertyField>(); PropertyInfo[] infos = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo info in infos) { if (!(info.CanRead && info.CanWrite)) { continue; } object[] attributes = info.GetCustomAttributes(true); bool isExposed = false; foreach (object o in attributes) { if (o.GetType() == typeof(ExposePropertyAttribute)) { isExposed = true; break; } } if (!isExposed) { continue; } SerializedPropertyType type = SerializedPropertyType.Integer; if (PropertyField.GetPropertyType(info, out type)) { PropertyField field = new PropertyField(obj, info, type); fields.Add(field); } } return(fields.ToArray()); }
public ChangeStringValueTool(System.Object data, string newValue, string getMethodName, string setMethodName, bool updateTree, bool updatePanel) { this.data = data; this.newValue = newValue; this.updatePanel = updatePanel; this.updateTree = updateTree; set = data.GetType().GetMethod(setMethodName); get = data.GetType().GetMethod(getMethodName); this.getName = getMethodName; this.setName = setMethodName; if (get.ReturnType != typeof(string)) { get = set = null; getName = setName = null; //ReportDialog.GenerateErrorReport(new Exception("Get method must return bool value"), false, // Language.GetText("Error.Title")); } }
private static bool CheckAssetAlive(System.Object asset) { if (null == asset) { return(false); } if (asset is Object) { Object UnityObject = asset as Object; if (null == UnityObject || !UnityObject) { return(false); } } else { throw new Exception(string.Format("InVaild Asset Type:{0}", asset.GetType())); } return(true); }