/** * Gets the operation name from an operation representation * * @param ope * the representation of the operation * @return the name of the operation */ public static string getOpName(Object ope) { string op = string.Empty; if (ope.Equals("=")) { op = EQUALS; } else if (ope.Equals(">")) { op = GRATER; } else if (ope.Equals("<")) { op = LESS; } else if (ope.Equals(">=")) { op = GRATER_EQ; } else if (ope.Equals("<=")) { op = LESS_EQ; } return(op); }
/** * Gets the operation representation from an operation name * * @param ope * the name of the operation * @return the representation of the operation */ public static string getOpRepresentation(Object ope) { string op = string.Empty; if (ope.Equals(EQUALS)) { op = "="; } else if (ope.Equals(GRATER)) { op = ">"; } else if (ope.Equals(LESS)) { op = "<"; } else if (ope.Equals(GRATER_EQ)) { op = ">="; } else if (ope.Equals(LESS_EQ)) { op = "<="; } return(op); }
/// <summary>Update the environment used.</summary> /// <param name="environmentOrCubemapAsset"> /// The new <see cref="Environment"/> to use. /// Or the <see cref="Cubemap"/> to use to build a new one. /// Other types will raise an ArgumentException. /// </param> public void UpdateEnvironment(UnityEngine.Object environmentOrCubemapAsset) { environmentGUID = ""; environment = null; if (environmentOrCubemapAsset == null || environmentOrCubemapAsset.Equals(null)) { return; } if (!(environmentOrCubemapAsset is Environment) && !(environmentOrCubemapAsset is Cubemap)) { throw new System.ArgumentException("Only Environment or Cubemap accepted for environmentOrCubemapAsset parameter"); } string GUID; long localIDInFile; AssetDatabase.TryGetGUIDAndLocalFileIdentifier(environmentOrCubemapAsset, out GUID, out localIDInFile); environmentGUID = $"{GUID},{localIDInFile}"; if (environmentOrCubemapAsset is Environment) { environment = environmentOrCubemapAsset as Environment; } else //Cubemap { environment = new Environment(); environment.sky.cubemap = environmentOrCubemapAsset as Cubemap; } }
// Add all the GameObject's in this container to the set public void AddGameObjectsTo(HashSet <GameObject> gameObjectsSet) { if (PendingSearch) { return; } CalculateShortestPathsToReferences(); for (int i = 0; i < referencePathsShortUnique.Count; i++) { Object obj = referencePathsShortUnique[i].startNode.UnityObject; if (obj != null && !obj.Equals(null)) { if (obj is GameObject) { gameObjectsSet.Add((GameObject)obj); } else if (obj is Component) { gameObjectsSet.Add(((Component)obj).gameObject); } } } }
void OnEnable() { m_CurrentPlatform = EditorUserBuildSettings.activeBuildTarget; m_AssetMetadata = ShaderAnalysisUtils.LoadAssetMetadatasFor(m_CurrentPlatform); m_AssetMetadataReference = ShaderAnalysisUtils.LoadAssetMetadatasFor(m_CurrentPlatform, referenceFolder); if (m_SupportedPlatformNames == null) { m_SupportedPlatformNames = EditorShaderTools.SupportedBuildTargets.Select(s => s.ToString()).ToArray(); m_SupportedPlatforms = EditorShaderTools.SupportedBuildTargets.ToArray(); } m_GUI = NOOPGUI; if (m_SelectedAsset != null && !m_SelectedAsset.Equals(null)) { OpenAsset(m_SelectedAsset); } if (m_SelectedPlatformIndex >= 0 && m_SelectedPlatformIndex < m_SupportedPlatforms.Length) { m_CurrentPlatform = m_SupportedPlatforms[m_SelectedPlatformIndex]; m_AssetMetadata = ShaderAnalysisUtils.LoadAssetMetadatasFor(m_CurrentPlatform); } if (!string.IsNullOrEmpty(referenceSourceFolderPath) && Directory.Exists(referenceSourceFolderPath) && m_CurrentPlatform != BuildTarget.NoTarget) { m_AssetMetadataReference = ShaderAnalysisUtils.LoadAssetMetadatasFor(m_CurrentPlatform, referenceFolder); } }
/// <summary>Update the environment used.</summary> /// <param name="environmentOrCubemapAsset"> /// The new <see cref="Environment"/> to use. /// Or the <see cref="Cubemap"/> to use to build a new one. /// Other types will raise an ArgumentException. /// </param> public void UpdateEnvironment(UnityEngine.Object environmentOrCubemapAsset) { environmentGUID = ""; environment = null; if (environmentOrCubemapAsset == null || environmentOrCubemapAsset.Equals(null)) { return; } if (!(environmentOrCubemapAsset is Environment) && !(environmentOrCubemapAsset is Cubemap)) { throw new System.ArgumentException("Only Environment or Cubemap accepted for environmentOrCubemapAsset parameter"); } environmentGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(environmentOrCubemapAsset)); if (environmentOrCubemapAsset is Environment) { environment = environmentOrCubemapAsset as Environment; } else //Cubemap { environment = new Environment(); environment.sky.cubemap = environmentOrCubemapAsset as Cubemap; } }
static public bool CheckValueIsNull(this MemberInfo pMemberInfo, object pTarget) { FieldInfo pFieldInfo = pMemberInfo as FieldInfo; if (pFieldInfo == null) { return(true); } object pObjectValue = pFieldInfo.GetValue(pTarget); if (pObjectValue == null) { return(true); } bool bResult; UnityEngine.Object pUnityObject = pObjectValue as UnityEngine.Object; if (pObjectValue is UnityEngine.Object) { bResult = pUnityObject.Equals(null); } else { bResult = pObjectValue.Equals(null); } return(bResult); }
///<summary> Method meant to prevent unwanted asset termination </summary> public static bool ValidatePrefabTermination <T>(T obj) where T : U.Object { if (obj == null) { EditorUtil.Debug("[ValidatePrefabTermination] NULL object"); return(false); } bool _validTermination = false; #if UNITY_EDITOR bool _isPrefab = false; U.Object _prefab = null; #if UNITY_2018_3_OR_NEWER _prefab = E.PrefabUtility.GetPrefabInstanceHandle(obj); #else _prefab = E.PrefabUtility.GetPrefabObject(obj); #endif _isPrefab = _prefab != null && _prefab.Equals(obj); if (!_isPrefab || !E.EditorUtility.DisplayDialog("Confirm action", "Seems like object " + obj.name + " is a prefab! This action will permanently delete the asset from your project!\nContinue?", "Yes", "No")) { _validTermination = true; } #else _validTermination = true; #endif return(_validTermination); }
void DistributeLimbs(Transform ragdollTransform, int no) { Limb limb; if (Object.Equals(ragdollTransform, rootBone.transform)) { limb = ragdollTransform.gameObject.AddComponent <LimbRoot>(); } else if (ragdollTransform.name.ToLower().Contains("leg") /*|| ragdollTransform.name.ToLower().Contains("thigh")*/) { limb = ragdollTransform.gameObject.AddComponent <LimbLeg>(); } else if (ragdollTransform.name.ToLower().Contains("arm")) { limb = ragdollTransform.gameObject.AddComponent <LimbArm>(); } else if (ragdollTransform.name.ToLower().Contains("head")) { limb = ragdollTransform.gameObject.AddComponent <LimbHead>(); } else { limb = ragdollTransform.gameObject.AddComponent <LimbDefault>(); } limb.No = no; AllLimbs.Add(limb); }
internal static bool IsNull(this UnityObject obj) { if (obj == null || obj.Equals(null)) { return(true); } return(false); }
public virtual void ChangeValue(UnityEngine.Object Org, UnityEngine.Object New) { if (Org == null || New == null) { return; } FieldInfo[] fields = base.GetType().GetFields(); FieldInfo[] array = fields; for (int i = 0; i < array.Length; i++) { FieldInfo fieldInfo = array[i]; UnityEngine.Object @object = fieldInfo.GetValue(this) as UnityEngine.Object; if (!(@object == null)) { Component component = @object as Component; if (component != null) { GameObject gameObject = Org as GameObject; if (!(gameObject == null)) { Component component2 = gameObject.GetComponent(component.GetType().Name); if (!(component2 == null)) { if (@object.Equals(component2)) { GameObject gameObject2 = New as GameObject; if (!(gameObject2 == null)) { Component component3 = gameObject2.GetComponent(component.GetType().Name); if (!(component3 == null)) { fieldInfo.SetValue(this, component3); } } } } } } else if (@object.Equals(Org)) { fieldInfo.SetValue(this, New); } } } }
public static string GetName(this Object obj) { if (obj == null || obj.Equals(null)) { return("None"); } return(obj.name); }
// Try replacing searched objects who are part of currently open prefab stage with their corresponding prefab assets public void ReplacePrefabStageObjectsWithAssets(PrefabStage prefabStage) { if (prefabStage == null || !prefabStage.stageHandle.IsValid()) { return; } #if UNITY_2020_1_OR_NEWER GameObject prefabAsset = AssetDatabase.LoadAssetAtPath <GameObject>(prefabStage.assetPath); #else GameObject prefabAsset = AssetDatabase.LoadAssetAtPath <GameObject>(prefabStage.prefabAssetPath); #endif if (prefabAsset == null || prefabAsset.Equals(null)) { return; } for (int i = 0; i < objectsToSearch.Count; i++) { Object obj = objectsToSearch[i].obj; if (obj != null && !obj.Equals(null) && obj is GameObject && prefabStage.IsPartOfPrefabContents((GameObject)obj)) { GameObject prefabStageObjectSource = ((GameObject)obj).FollowSymmetricHierarchy(prefabStage.prefabContentsRoot, prefabAsset); if (prefabStageObjectSource != null) { objectsToSearch[i].obj = prefabStageObjectSource; } List <ObjectToSearch.SubAsset> subAssets = objectsToSearch[i].subAssets; for (int j = 0; j < subAssets.Count; j++) { obj = subAssets[j].subAsset; if (obj != null && !obj.Equals(null) && obj is GameObject && prefabStage.IsPartOfPrefabContents((GameObject)obj)) { prefabStageObjectSource = ((GameObject)obj).FollowSymmetricHierarchy(prefabStage.prefabContentsRoot, prefabAsset); if (prefabStageObjectSource != null) { subAssets[j].subAsset = prefabStageObjectSource; } } } } } }
static int Equals(IntPtr l) { luaMgr.CheckArgsCount(2); Object obj = (Object)luaMgr.GetNetObject(1); object arg0 = (object)luaMgr.GetNetObject(2); bool o = obj.Equals(arg0); luaMgr.PushResult(o); return(1); }
static int Equals(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); Object obj = LuaScriptMgr.GetNetObject <Object>(L, 1); object arg0 = LuaScriptMgr.GetVarObject(L, 2); bool o = obj.Equals(arg0); LuaScriptMgr.Push(L, o); return(1); }
private static int Equals(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); UnityEngine.Object @object = LuaScriptMgr.GetVarObject(L, 1) as UnityEngine.Object; object varObject = LuaScriptMgr.GetVarObject(L, 2); bool b = (!(@object != null)) ? (varObject == null) : @object.Equals(varObject); LuaScriptMgr.Push(L, b); return(1); }
static int Equals(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); Object obj = LuaScriptMgr.GetVarObject(L, 1) as Object; object arg0 = LuaScriptMgr.GetVarObject(L, 2); bool o = obj != null?obj.Equals(arg0) : arg0 == null; LuaScriptMgr.Push(L, o); return(1); }
static int Equals(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); Object obj = (Object)LuaScriptMgr.GetNetObject(L, 1); object arg0 = (object)LuaScriptMgr.GetNetObject(L, 2); bool o = obj.Equals(arg0); LuaScriptMgr.PushResult(L, o); return(1); }
void NOOPGUI() { EditorGUI.BeginChangeCheck(); m_SelectedAsset = EditorGUILayout.ObjectField(EditorGUIUtility.TrTempContent("To Inspect"), m_SelectedAsset, typeof(Object), false); if (EditorGUI.EndChangeCheck() && m_SelectedAsset != null && !m_SelectedAsset.Equals(null)) { OpenAsset(m_SelectedAsset); } }
static int Equals(IntPtr L) { L.ChkArgsCount(2); Object obj = L.ToAnyObject(1) as Object; var arg0 = L.ToAnyObject(2); bool o = obj != null?obj.Equals(arg0) : arg0 == null; L.PushBoolean(o); return(1); }
// Try replacing searched objects who are part of currently open prefab stage with their corresponding prefab assets public void ReplacePrefabStageObjectsWithAssets(UnityEditor.Experimental.SceneManagement.PrefabStage prefabStage) { if (prefabStage == null || !prefabStage.stageHandle.IsValid()) { return; } GameObject prefabAsset = AssetDatabase.LoadAssetAtPath <GameObject>(prefabStage.prefabAssetPath); if (prefabAsset == null) { return; } for (int i = 0; i < objectsToSearch.Count; i++) { Object obj = objectsToSearch[i].obj; if (obj != null && !obj.Equals(null) && obj is GameObject && prefabStage.IsPartOfPrefabContents((GameObject)obj)) { GameObject prefabStageObjectSource = ((GameObject)obj).FollowSymmetricHierarchy(prefabAsset); if (prefabStageObjectSource != null) { objectsToSearch[i].obj = prefabStageObjectSource; } List <ObjectToSearch.SubAsset> subAssets = objectsToSearch[i].subAssets; for (int j = 0; j < subAssets.Count; j++) { obj = subAssets[j].subAsset; if (obj != null && !obj.Equals(null) && obj is GameObject && prefabStage.IsPartOfPrefabContents((GameObject)obj)) { prefabStageObjectSource = ((GameObject)obj).FollowSymmetricHierarchy(prefabAsset); if (prefabStageObjectSource != null) { subAssets[j].subAsset = prefabStageObjectSource; } } } } } }
public static T GetResource <T>(string name) where T : Object { T resource = Resources.Load <T>(name); if (Object.Equals(resource, null)) { throw new FileNotFoundException("An asset of type: " + typeof(T).Name + " file named \"" + name + "\" needs to be located in a Resources folder"); } return(resource); }
public static string CalculateGUIDFor(Object asset) { if (asset == null || asset.Equals(null)) { return(string.Empty); } var assetPath = AssetDatabase.GetAssetPath(asset); var guid = string.IsNullOrEmpty(assetPath) ? asset.name : AssetDatabase.AssetPathToGUID(assetPath); return(guid); }
public virtual void Release(Object owner) { for (int i = 0, l = m_Owners.Count; i < l; ++i) { if (owner.Equals(m_Owners[i].Target)) { m_Owners.RemoveAt(i); break; } } CheckRefCount(); }
// Add all the Object's in this container to the set public void AddObjectsTo(HashSet <Object> objectsSet) { CalculateShortestPathsToReferences(); for (int i = 0; i < referencePathsShortUnique.Count; i++) { Object obj = referencePathsShortUnique[i].startNode.UnityObject; if (obj != null && !obj.Equals(null)) { objectsSet.Add(obj); } } }
public void AddReference(UnityObject obj) { _readyTime = Time.time; int idx = _references.FindIndex(r => obj.Equals(r.Target)); if (idx >= 0) { return; } WeakReference wr = new WeakReference(obj); _references.Add(wr); }
public static bool obj_equal(long L, long R) { UnityObject left = FCGetObj.GetObj <UnityObject>(L); UnityObject right = FCGetObj.GetObj <UnityObject>(R); if (left != null) { return(left.Equals(right)); } if (right != null) { return(right.Equals(left)); } return(true); }
static new public int Equals(IntPtr l) { try { UnityEngine.Object self = (UnityEngine.Object)checkSelf(l); System.Object a1; checkType(l, 2, out a1); var ret = self.Equals(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
public static Texture GetTexture(this Object obj) { if (obj != null && !obj.Equals(null)) { if (obj is Texture) { return((Texture)obj); } else if (obj is Sprite) { return(((Sprite)obj).texture); } } return(null); }
static int Equals(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.Object obj = (UnityEngine.Object)ToLua.CheckObject(L, 1, typeof(UnityEngine.Object)); object arg0 = ToLua.ToVarObject(L, 2); bool o = obj != null ? obj.Equals(arg0) : arg0 == null; LuaDLL.lua_pushboolean(L, o); return 1; } catch(Exception e) { return LuaDLL.toluaL_exception(L, e); } }
/** * Gets the operation name from an operation representation * * @param ope * the representation of the operation * @return the name of the operation */ public static string getOpName(Object ope) { string op = string.Empty; if (ope.Equals("=")) { op = EQUALS; } else if (ope.Equals(">")) { op = GRATER; } else if (ope.Equals("<")) { op = LESS; } else if (ope.Equals(">=")) { op = GRATER_EQ; } else if (ope.Equals("<=")) { op = LESS_EQ; } return op; }
/** * Gets the operation representation from an operation name * * @param ope * the name of the operation * @return the representation of the operation */ public static string getOpRepresentation(Object ope) { string op = string.Empty; if (ope.Equals(EQUALS)) { op = "="; } else if (ope.Equals(GRATER)) { op = ">"; } else if (ope.Equals(LESS)) { op = "<"; } else if (ope.Equals(GRATER_EQ)) { op = ">="; } else if (ope.Equals(LESS_EQ)) { op = "<="; } return op; }
/// <summary> /// 增加引用 /// </summary> /// <param name="owner">用来计算引用计数,如果所有的引用对象被销毁了,那么AB也将会被销毁</param> public void Retain(Object owner) { if (owner == null) throw new Exception("Please set the user!"); for (int i = 0; i < references.Count; i++) { if (owner.Equals(references[i].Target)) return; } WeakReference wr = new WeakReference(owner); references.Add(wr); }