public override void OnDeserialization() { popupLabel = "Replace Another Property"; typeHash = new Dictionary <Type, ReplaceItem>(); if (objID == null) { objID = new ObjectID(); } objID.OnDeserialization(); if (searchProperty == null) { searchProperty = new PropertyPopupData(); } searchProperty.label = "Property:"; searchProperty.SetType(objID.obj); initializationContext = new InitializationContext(searchProperty.fieldData, objID.obj); initSubItem <ReplaceItemString>(new List <Type>() { typeof(string) }, ref replaceItemString); initSubItem <ReplaceItemFloat>(new List <Type>() { typeof(float) }, ref replaceItemFloat); initSubItem <ReplaceItemObject>(new List <Type>() { typeof(UnityEngine.Object) }, ref replaceItemObject); initSubItem <ReplaceItemInt>(new List <Type>() { typeof(int), typeof(uint), typeof(short), typeof(ushort), typeof(byte), typeof(sbyte), }, ref replaceItemInt); initSubItem <ReplaceItemDouble>(new List <Type>() { typeof(double) }, ref replaceItemDouble); initSubItem <ReplaceItemBool>(new List <Type>() { typeof(bool) }, ref replaceItemBool); initSubItem <ReplaceItemChar>(new List <Type>() { typeof(char) }, ref replaceItemChar); initSubItem <ReplaceItemVector2>(new List <Type>() { typeof(Vector2) }, ref replaceItemVector2); initSubItem <ReplaceItemVector3>(new List <Type>() { typeof(Vector3) }, ref replaceItemVector3); initSubItem <ReplaceItemVector4>(new List <Type>() { typeof(Vector4) }, ref replaceItemVector4); initSubItem <ReplaceItemRect>(new List <Type>() { typeof(Rect) }, ref replaceItemRect); initSubItem <ReplaceItemColor>(new List <Type>() { typeof(Color), typeof(Color32) }, ref replaceItemColor); initSubItem <ReplaceItemQuaternion>(new List <Type>() { typeof(Quaternion) }, ref replaceItemQuaternion); initSubItem <ReplaceItemEnum>(new List <Type>() { typeof(Enum) }, ref replaceItemEnum); type = null; if (objID.obj != null) { setType(initializationContext.fieldData.fieldType); } }
public ObjectID Copy() { ObjectID retVal = new ObjectID(obj); return(retVal); }
public static List <SearchAssetData> GetAssets(SearchScopeData scope) { List <SearchAssetData> retVal = new List <SearchAssetData>(); if (scope.projectScope == ProjectScope.EntireProject) { //If the asset scope is set and has this value OR the scope is not set at all (everything) HashSet <string> suffixes = scope.GetSuffixesForScope(); string[] allAssets = AssetDatabase.GetAllAssetPaths(); IEnumerable <string> filteredPaths = allAssets.Where(asset => asset.StartsWith("Assets/")).Where(asset => suffixes.Contains(Path.GetExtension(asset).ToLowerInvariant())); foreach (string asset in filteredPaths) { AddAsset(asset, retVal); } } else if (scope.projectScope == ProjectScope.SceneView) { SceneViewSearchAssetData sceneView = new SceneViewSearchAssetData(SceneUtil.GuidPathForActiveScene()); retVal.Add(sceneView); } else if (scope.projectScope == ProjectScope.SpecificLocation) { string[] allAssets = null; HashSet <string> suffixes = scope.GetSuffixesForScope(); addObjectsInLocation(scope.scopeObj, ref allAssets, suffixes, retVal); } else if (scope.projectScope == ProjectScope.CurrentSelection) { string[] allAssets = null; SceneObjectSearchAssetData sceneObject = null; foreach (UnityEngine.Object obj in Selection.objects) { HashSet <string> suffixes = scope.GetSuffixesForScope(SearchScope.allAssets); ObjectID objID = new ObjectID(obj); objID.Clear(); if (objID.isSceneObject) { GameObject go = (GameObject)obj; if (sceneObject == null) { sceneObject = new SceneObjectSearchAssetData(go.scene.path); retVal.Add(sceneObject); } sceneObject.AddObject(go); } else if (objID.isPrefabStageObject) { if (sceneObject == null) { sceneObject = new SceneObjectSearchAssetData(SceneUtil.GuidPathForActiveScene()); retVal.Add(sceneObject); } sceneObject.AddObject((GameObject)obj); } else { //Ignore asset scope for current selection. addObjectsInLocation(objID, ref allAssets, suffixes, retVal); } } } return(retVal); }