public static void _revert() { var fonts = Resources.FindObjectsOfTypeAll(typeof(Font)); Font[] lst = new Font[0]; foreach (var p in LucidaGrande) { var fontAsset = (Font)ArrayUtility.Find(fonts, a => a.name == p); ArrayUtility.Add(ref lst, fontAsset); } //foreach( var aa in lst ) { // Debug.Log(aa.name); //} try { if (!_set(lst)) { return; } s_Apply = false; } catch (System.Exception e) { Debug.LogError(e); } EditorApplication.update -= _revert; }
private static bool CanToggle() { var window = Resources.FindObjectsOfTypeAll <EditorWindow>(); var inspectorWindow = ArrayUtility.Find(window, c => c.GetType().Name == "InspectorWindow"); return(inspectorWindow != null); }
private static void ProcessState(AnimatorState state) { if (!ArrayUtility.Find(state.behaviours, x => x is AnimatorRelay)) { state.AddStateMachineBehaviour <AnimatorRelay> (); } }
private AudioSource CheckForHiddenAudioSources() { AudioSource[] sources = script.gameObject.GetComponents <AudioSource>(); List <AudioSource> eligibleSources = new List <AudioSource>(); foreach (AudioSource aSource in sources) { if (aSource.hideFlags == (HideFlags.HideInInspector | HideFlags.NotEditable)) { eligibleSources.Add(aSource); } } if (eligibleSources.Count == 0) { return(null); } AudioSourcePro[] pros = script.gameObject.GetComponents <AudioSourcePro>(); foreach (AudioSource eligibleSource in eligibleSources) { AudioSourcePro tempPro = ArrayUtility.Find <AudioSourcePro>(pros, delegate(AudioSourcePro obj) { return(obj.audioSource == eligibleSource); }); if (tempPro == null) { return(eligibleSource); } } return(null); }
static void RigOptimizeGameObject() { Regex[] extraTransformNames = { new Regex("Bip\\d+ HeadNub"), new Regex("Bip\\d+ Spine") }; Object[] models = Selection.GetFiltered(typeof(GameObject), SelectionMode.DeepAssets); List <string> extraTransformPaths = new List <string>(); foreach (GameObject model in models) { string path = AssetDatabase.GetAssetPath(model); ModelImporter mi = AssetImporter.GetAtPath(path) as ModelImporter; string[] transformPaths = mi.transformPaths; extraTransformPaths.Clear(); foreach (Regex regex in extraTransformNames) { string transformPath = ArrayUtility.Find(transformPaths, (string p) => { var name = Path.GetFileName(p); return(regex.IsMatch(name)); }); if (transformPath != null) { extraTransformPaths.Add(transformPath); } } mi.optimizeGameObjects = true; if (extraTransformPaths.Count > 0) { mi.extraExposedTransformPaths = extraTransformPaths.ToArray(); } mi.SaveAndReimport(); } }
public Hash128 GetAssetBundleHash(string assetBundleName) { var v = ArrayUtility.Find(builds, (a) => a.assetBundleName == assetBundleName); if (v == null) { return(Hash128.Parse("")); } return(Hash128.Parse(v.hash)); }
public string[] GetDirectDependencies(string assetBundleName) { var v = ArrayUtility.Find(builds, (a) => a.assetBundleName == assetBundleName); if (v == null) { return(new string[0]); } return(v.dependency); }
void ReplaceCustomStyle(string name) { GUIStyle style = ArrayUtility.Find(_skinOriginal.customStyles, s => s.name == name.ToString()); int index = ArrayUtility.FindIndex(_skinTarget.customStyles, s => s.name == name.ToString()); if (style != null && index > -1) { _skinTarget.customStyles[index] = style; } }
public void PatchAsset(string path, PatchBy patch) { var asset = ArrayUtility.Find(assets, bundleAsset => bundleAsset.path.Equals(path)); if (asset != null) { asset.patch = patch; return; } ArrayUtility.Add(ref assets, new AssetBuild() { path = path, patch = patch, }); }
public void GroupAsset(string path, BundleNameBy nameBy = BundleNameBy.Filename) { var asset = ArrayUtility.Find(assets, assetBuild => assetBuild.path.Equals(path)); if (asset != null) { asset.nameBy = nameBy; return; } ArrayUtility.Add(ref assets, new AssetBuild() { path = path, nameBy = nameBy, }); }
public void GroupAsset(string path, GroupBy groupBy = GroupBy.Filename) { var asset = ArrayUtility.Find(assets, build => build.path.Equals(path)); if (asset != null) { asset.groupBy = groupBy; return; } ArrayUtility.Add(ref assets, new AssetBuild() { path = path, groupBy = groupBy, }); }
private static UnityEditor.Animations.AnimatorState CreateState(UnityEditor.Animations.AnimatorStateMachine machine, string name, AnimationClip anim, Vector3 pos) { foreach (var item in machine.states) { if (item.state.name == name) { return(item.state); } } UnityEditor.Animations.AnimatorState state = machine.AddState(name); state.motion = anim; //state.SetAnimationClip(anim); var state1 = ArrayUtility.Find <UnityEditor.Animations.ChildAnimatorState>(machine.states, x => x.state == state); state1.position = pos; //state.position = pos; return(state); }
public void GroupAsset(string path, GroupBy groupBy = GroupBy.Filename) { bool Match(AssetBuild bundleAsset) { return(bundleAsset.path.Equals(path)); } var asset = ArrayUtility.Find(assets, Match); if (asset != null) { asset.groupBy = groupBy; return; } ArrayUtility.Add(ref assets, new AssetBuild() { path = path, groupBy = groupBy, }); }
[MenuItem("Tools/Inspector DebugMode %t")] // Ctrl + t static void DebugModeInspector() { var window = Resources.FindObjectsOfTypeAll <EditorWindow>(); var inspectorWindow = ArrayUtility.Find(window, c => c.GetType().Name == "InspectorWindow"); if (inspectorWindow == null) { return; } var inspectorType = inspectorWindow.GetType(); var tracker = ActiveEditorTracker.sharedTracker; var isNormal = tracker.inspectorMode == InspectorMode.Normal; var methodName = isNormal ? "SetDebug" : "SetNormal"; var methodInfo = inspectorType.GetMethod(methodName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); methodInfo.Invoke(inspectorWindow, null); tracker.ForceRebuild(); }
public void PatchAsset(string path, PatchId patch) { bool Match(AssetBuild bundleAsset) { return(bundleAsset.path.Equals(path)); } var asset = ArrayUtility.Find(assets, Match); if (asset != null) { asset.patch = patch; return; } ArrayUtility.Add(ref assets, new AssetBuild() { path = path, patch = patch, }); }
void OnEnable() { string styleMode = EditorPrefs.GetString(KEY_STYLE, "Settings"); string stateMode = EditorPrefs.GetString(KEY_STATE, "Settings"); styleEditMode = (GUIStyleEditMode)System.Enum.Parse(typeof(GUIStyleEditMode), styleMode); stateEditMode = (GUIStateEditMode)System.Enum.Parse(typeof(GUIStateEditMode), stateMode); previewControlIndex = EditorPrefs.GetInt(KEY_PREV_ID, 0); foldBorder = foldMargin = foldOverflow = foldPadding = foldFont = false; ResetCustomStyles(); GUISkin editor = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector); findStyleName = "ToolbarSeachTextField"; searchTextField = ArrayUtility.Find <GUIStyle>(editor.customStyles, MatchCustomStyle); findStyleName = "ToolbarSeachCancelButton"; searchClearButton = ArrayUtility.Find <GUIStyle>(editor.customStyles, MatchCustomStyle); findStyleName = "ToolbarPopup"; previewToolbarPopup = ArrayUtility.Find <GUIStyle>(editor.customStyles, MatchCustomStyle); }
private void TryBuild(Entity entity, GameObject prefab, GameObject instance, string directory, string prefabPath, IDictionary <int, IDictionary <int, Sprite> > folders) { var controllerPath = string.Format("{0}/{1}.controller", directory, entity.name); var animator = instance.GetComponent <Animator> (); //Fetches the prefab's Animator if (animator == null) { animator = instance.AddComponent <Animator> (); //Or creates one if it doesn't exist } AnimatorController controller = null; if (animator.runtimeAnimatorController != null) //The controller we use is hopefully the controller attached to the animator { controller = animator.runtimeAnimatorController as AnimatorController ?? //Or the one that's referenced by an OverrideController (AnimatorController)((AnimatorOverrideController)animator.runtimeAnimatorController).runtimeAnimatorController; } if (controller == null) //Otherwise we have to check the AssetDatabase for our controller { controller = (AnimatorController)AssetDatabase.LoadAssetAtPath(controllerPath, typeof(AnimatorController)); if (controller == null) { controller = AnimatorController.CreateAnimatorControllerAtPath(controllerPath); //Or create a new one if it doesn't exist. ProcessingInfo.NewControllers.Add(controller); } animator.runtimeAnimatorController = controller; } var transforms = new Dictionary <string, Transform> (); //All of the bones and sprites, identified by TimeLine.name, because those are truly unique transforms ["rootTransform"] = instance.transform; //The root GameObject needs to be part of this hierarchy as well var defaultBones = new Dictionary <string, SpatialInfo> (); //These are basically the object states on the first frame of the first animation var defaultSprites = new Dictionary <string, SpriteInfo> (); //They are used as control values in determining whether something has changed var animBuilder = new AnimationBuilder(ProcessingInfo, folders, transforms, defaultBones, defaultSprites, prefabPath, controller); var firstAnim = true; //The prefab's graphic will be determined by the first frame of the first animation foreach (var animation in entity.animations) { var timeLines = new Dictionary <int, TimeLine> (); foreach (var timeLine in animation.timelines) //TimeLines hold all the critical data such as positioning and graphics used { timeLines [timeLine.id] = timeLine; } foreach (var key in animation.mainlineKeys) { var parents = new Dictionary <int, string> (); //Parents are referenced by different IDs V_V parents [-1] = "rootTransform"; //This is where "-1 == no parent" comes in handy var boneRefs = new Queue <Ref> (key.boneRefs ?? new Ref[0]); while (boneRefs.Count > 0) { var bone = boneRefs.Dequeue(); var timeLine = timeLines [bone.timeline]; parents [bone.id] = timeLine.name; if (!transforms.ContainsKey(timeLine.name)) //We only need to go through this once, so ignore it if it's already in the dict { if (parents.ContainsKey(bone.parent)) //If the parent cannot be found, it will probably be found later, so save it { var parentID = parents [bone.parent]; var parent = transforms [parentID]; var child = parent.Find(timeLine.name); //Try to find the child transform if it exists if (child == null) //Or create a new one { child = new GameObject(timeLine.name).transform; child.SetParent(parent); } transforms [timeLine.name] = child; var spatialInfo = defaultBones [timeLine.name] = ArrayUtility.Find(timeLine.keys, x => x.id == bone.key).info; if (!spatialInfo.processed) { SpatialInfo parentInfo; defaultBones.TryGetValue(parentID, out parentInfo); spatialInfo.Process(parentInfo); } child.localPosition = new Vector3(spatialInfo.x, spatialInfo.y, 0f); child.localRotation = spatialInfo.rotation; child.localScale = new Vector3(spatialInfo.scale_x, spatialInfo.scale_y, 1f); } else { boneRefs.Enqueue(bone); } } } foreach (var oref in key.objectRefs) { var timeLine = timeLines [oref.timeline]; if (!transforms.ContainsKey(timeLine.name)) //Same as above { var parentID = parents [oref.parent]; var parent = transforms [parentID]; var child = parent.Find(timeLine.name); if (child == null) { child = new GameObject(timeLine.name).transform; child.SetParent(parent); } transforms [timeLine.name] = child; var swapper = child.GetComponent <TextureController> (); //Destroy the Sprite Swapper, we'll make a new one later if (swapper != null) { DestroyImmediate(swapper); } var renderer = child.GetComponent <SpriteRenderer> (); //Get or create a Sprite Renderer if (renderer == null) { renderer = child.gameObject.AddComponent <SpriteRenderer> (); } var spriteInfo = defaultSprites [timeLine.name] = (SpriteInfo)ArrayUtility.Find(timeLine.keys, x => x.id == 0).info; renderer.sprite = folders [spriteInfo.folder] [spriteInfo.file]; if (!spriteInfo.processed) { SpatialInfo parentInfo; defaultBones.TryGetValue(parentID, out parentInfo); spriteInfo.Process(parentInfo); } child.localPosition = new Vector3(spriteInfo.x, spriteInfo.y, oref.z_index); //Z-index helps determine draw order child.localEulerAngles = new Vector3(0f, 0f, spriteInfo.angle); //The reason I don't use layers or layer orders is because child.localScale = new Vector3(spriteInfo.scale_x, spriteInfo.scale_y, 1f); //There tend to be a LOT of body parts, it's better to treat var color = renderer.color; //The entity as a single sprite for layer sorting purposes. color.a = spriteInfo.a; renderer.color = color; if (!firstAnim) { child.gameObject.SetActive(false); //Disable the GameObject if this isn't the first frame of the first animation } } } if (firstAnim) { firstAnim = false; } } try { animBuilder.Build(animation, timeLines); //Builds the currently processed AnimationClip, see AnimationBuilder for more info } catch (Exception e) { Debug.LogErrorFormat("Unable to build animation '{0}' for '{1}', reason: {2}", animation.name, entity.name, e); } } if (instance.GetComponent <EntityRenderer> () == null) { instance.AddComponent <EntityRenderer> (); //Adds an EntityRenderer if one is not already present } PrefabUtility.ReplacePrefab(instance, prefab, ReplacePrefabOptions.ConnectToPrefab); DestroyImmediate(instance); //Apply the instance's changes to the prefab, then destroy the instance. }
void AddCopyCustomStyle(string name) { GUIStyle style = ArrayUtility.Find(_skinOriginal.customStyles, s => s.name == name.ToString()); AddCopyCustomStyle(_skinTarget, style); }
//This is for curves that are tracked slightly differently from regular curves: Active curve and Z-index curve private void SetAdditionalCurves(Transform child, MainLineKey[] keys, TimeLine timeLine, AnimationClip clip, float defaultZ) { var positionChanged = false; var kfsZ = new List <Keyframe> (); var changedZ = false; var active = child.gameObject.activeSelf; //If the sprite or bone isn't present in the mainline, var kfsActive = new List <Keyframe> (); //Disable the GameObject if it isn't already disabled var childPath = GetPathToChild(child); foreach (var key in keys) //If it is present, enable the GameObject if it isn't already enabled { var mref = ArrayUtility.Find(key.objectRefs, x => x.timeline == timeLine.id); if (mref != null) { if (defaultZ == inf) { defaultZ = mref.z_index; positionChanged = true; } if (!changedZ && mref.z_index != defaultZ) { changedZ = true; if (key.time > 0) { kfsZ.Add(new Keyframe(0f, defaultZ, inf, inf)); } } if (changedZ) { kfsZ.Add(new Keyframe(key.time, mref.z_index, inf, inf)); } if (!active) { if (kfsActive.Count <= 0 && key.time > 0) { kfsActive.Add(new Keyframe(0f, 0f, inf, inf)); } kfsActive.Add(new Keyframe(key.time, 1f, inf, inf)); active = true; } } else if (active) { if (kfsActive.Count <= 0 && key.time > 0) { kfsActive.Add(new Keyframe(0f, 1f, inf, inf)); } kfsActive.Add(new Keyframe(key.time, 0f, inf, inf)); active = false; } } //Only add these curves if there is actually a mutation if (kfsZ.Count > 0) { clip.SetCurve(childPath, typeof(Transform), "localPosition.z", new AnimationCurve(kfsZ.ToArray())); if (!positionChanged) { var info = timeLine.keys [0].info; //If these curves don't actually exist, add some empty ones clip.SetCurve(childPath, typeof(Transform), "localPosition.x", new AnimationCurve(new Keyframe(0f, info.x))); clip.SetCurve(childPath, typeof(Transform), "localPosition.y", new AnimationCurve(new Keyframe(0f, info.y))); } } if (kfsActive.Count > 0) { clip.SetCurve(childPath, typeof(GameObject), "m_IsActive", new AnimationCurve(kfsActive.ToArray())); } }
static public void UpdateCache() { // Deserialize the cache from the unity resources if (eventCache == null) { eventCache = AssetDatabase.LoadAssetAtPath(CacheAssetFullName, typeof(EventCache)) as EventCache; if (eventCache == null || eventCache.cacheVersion != EventCache.CurrentCacheVersion) { UnityEngine.Debug.Log("FMOD Studio: Cannot find serialized event cache or cache in old format, creating new instance"); eventCache = ScriptableObject.CreateInstance <EventCache>(); eventCache.cacheVersion = EventCache.CurrentCacheVersion; AssetDatabase.CreateAsset(eventCache, CacheAssetFullName); } } if (EditorUtils.GetBankDirectory() == null) { ClearCache(); return; } string defaultBankFolder = null; if (!Settings.Instance.HasPlatforms) { defaultBankFolder = EditorUtils.GetBankDirectory(); } else { FMODPlatform platform = RuntimeUtils.GetEditorFMODPlatform(); if (platform == FMODPlatform.None) { platform = FMODPlatform.PlayInEditor; } defaultBankFolder = Path.Combine(EditorUtils.GetBankDirectory(), Settings.Instance.GetBankPlatform(platform)); } string[] bankPlatforms = EditorUtils.GetBankPlatforms(); string[] bankFolders = new string[bankPlatforms.Length]; for (int i = 0; i < bankPlatforms.Length; i++) { bankFolders[i] = Path.Combine(EditorUtils.GetBankDirectory(), bankPlatforms[i]); } List <String> stringBanks = new List <string>(0); try { var files = Directory.GetFiles(defaultBankFolder, "*." + StringBankExtension); stringBanks = new List <string>(files); } catch { } // Strip out OSX resource-fork files that appear on FAT32 stringBanks.RemoveAll((x) => Path.GetFileName(x).StartsWith("._")); if (stringBanks.Count == 0) { bool wasValid = eventCache.StringsBankWriteTime != DateTime.MinValue; ClearCache(); if (wasValid) { UnityEngine.Debug.LogError(String.Format("FMOD Studio: Directory {0} doesn't contain any banks. Build from the tool or check the path in the settings", defaultBankFolder)); } return; } // If we have multiple .strings.bank files find the most recent stringBanks.Sort((a, b) => File.GetLastWriteTime(b).CompareTo(File.GetLastWriteTime(a))); // Use the most recent string bank timestamp as a marker for the most recent build of any bank because it gets exported every time DateTime lastWriteTime = File.GetLastWriteTime(stringBanks[0]); if (lastWriteTime == eventCache.StringsBankWriteTime) { countdownTimer = CountdownTimerReset; return; } if (EditorUtils.IsFileOpenByStudio(stringBanks[0])) { countdownTimer = CountdownTimerReset; return; } // Most recent strings bank is newer than last cache update time, recache. // Get a list of all banks HashSet <string> bankFileNames = new HashSet <string>(); List <string> reducedStringBanksList = new List <string>(); HashSet <Guid> stringBankGuids = new HashSet <Guid>(); foreach (string stringBankPath in stringBanks) { FMOD.Studio.Bank stringBank; EditorUtils.CheckResult(EditorUtils.System.loadBankFile(stringBankPath, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out stringBank)); if (!stringBank.isValid()) { countdownTimer = CountdownTimerReset; return; } try { Guid stringBankGuid; EditorUtils.CheckResult(stringBank.getID(out stringBankGuid)); if (!stringBankGuids.Add(stringBankGuid)) { // If we encounter multiple string banks with the same GUID then only use the first. This handles the scenario where // a Studio project is cloned and extended for DLC with a new master bank name. continue; } reducedStringBanksList.Add(stringBankPath); // Iterate every string in the strings bank and look for any that identify banks int stringCount; stringBank.getStringCount(out stringCount); for (int stringIndex = 0; stringIndex < stringCount; stringIndex++) { string currentString; Guid currentGuid; stringBank.getStringInfo(stringIndex, out currentGuid, out currentString); const string BankPrefix = "bank:/"; int BankPrefixLength = BankPrefix.Length; if (currentString.StartsWith(BankPrefix)) { string bankFileName = currentString.Substring(BankPrefixLength) + "." + BankExtension; if (!bankFileName.Contains(StringBankExtension)) // filter out the strings bank { bankFileNames.Add(bankFileName); } } } } finally { // Unload the strings bank stringBank.unload(); } } stringBanks = reducedStringBanksList; // Check if any of the files are still being written by studio foreach (string bankFileName in bankFileNames) { string bankPath = Path.Combine(defaultBankFolder, bankFileName); if (!File.Exists(bankPath)) { // TODO: this is meant to catch the case where we're in the middle of a build and a bank is being built // for the first time. But it also stops someone trying to import an incomplete set of banks without any error message. countdownTimer = CountdownTimerReset; return; } EditorBankRef bankRef = eventCache.EditorBanks.Find((x) => bankPath == x.Path); if (bankRef == null) { if (EditorUtils.IsFileOpenByStudio(bankPath)) { countdownTimer = CountdownTimerReset; return; } continue; } if (bankRef.LastModified != File.GetLastWriteTime(bankPath)) { if (EditorUtils.IsFileOpenByStudio(bankPath)) { countdownTimer = CountdownTimerReset; return; } } } // Count down the timer in case we catch studio in-between updating two files. if (countdownTimer-- > 0) { return; } eventCache.StringsBankWriteTime = lastWriteTime; // All files are finished being modified by studio so update the cache // Stop editor preview so no stale data being held EditorUtils.PreviewStop(); // Reload the strings banks List <FMOD.Studio.Bank> loadedBanks = new List <FMOD.Studio.Bank>(); try { AssetDatabase.StartAssetEditing(); eventCache.EditorBanks.ForEach((x) => x.Exists = false); HashSet <string> masterBankFileNames = new HashSet <string>(); foreach (string stringBankPath in stringBanks) { FMOD.Studio.Bank stringBank; EditorUtils.CheckResult(EditorUtils.System.loadBankFile(stringBankPath, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out stringBank)); if (!stringBank.isValid()) { ClearCache(); return; } loadedBanks.Add(stringBank); FileInfo stringBankFileInfo = new FileInfo(stringBankPath); string masterBankFileName = Path.GetFileName(stringBankPath).Replace(StringBankExtension, BankExtension); masterBankFileNames.Add(masterBankFileName); EditorBankRef stringsBankRef = eventCache.StringsBanks.Find(x => stringBankPath == x.Path); if (stringsBankRef == null) { stringsBankRef = ScriptableObject.CreateInstance <EditorBankRef>(); stringsBankRef.FileSizes = new List <EditorBankRef.NameValuePair>(); eventCache.EditorBanks.Add(stringsBankRef); AssetDatabase.AddObjectToAsset(stringsBankRef, eventCache); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(stringsBankRef)); eventCache.StringsBanks.Add(stringsBankRef); } stringsBankRef.Path = stringBankPath; stringsBankRef.LastModified = stringBankFileInfo.LastWriteTime; stringsBankRef.Exists = true; stringsBankRef.FileSizes.Clear(); if (Settings.Instance.HasPlatforms) { for (int i = 0; i < bankPlatforms.Length; i++) { stringsBankRef.FileSizes.Add(new EditorBankRef.NameValuePair(bankPlatforms[i], stringBankFileInfo.Length)); } } else { stringsBankRef.FileSizes.Add(new EditorBankRef.NameValuePair("", stringBankFileInfo.Length)); } } string[] folderContents = Directory.GetFiles(defaultBankFolder); foreach (string bankFileName in bankFileNames) { // Get the true file path, can't trust the character case we got from the string bank string bankPath = ArrayUtility.Find(folderContents, x => (string.Equals(bankFileName, Path.GetFileName(x), StringComparison.CurrentCultureIgnoreCase))); FileInfo bankFileInfo = new FileInfo(bankPath); EditorBankRef bankRef = eventCache.EditorBanks.Find((x) => bankFileInfo.FullName == x.Path); // New bank we've never seen before if (bankRef == null) { bankRef = ScriptableObject.CreateInstance <EditorBankRef>(); AssetDatabase.AddObjectToAsset(bankRef, eventCache); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(bankRef)); bankRef.Path = bankFileInfo.FullName; bankRef.LastModified = DateTime.MinValue; bankRef.FileSizes = new List <EditorBankRef.NameValuePair>(); eventCache.EditorBanks.Add(bankRef); } bankRef.Exists = true; // Timestamp check - if it doesn't match update events from that bank if (bankRef.LastModified != bankFileInfo.LastWriteTime) { bankRef.LastModified = bankFileInfo.LastWriteTime; UpdateCacheBank(bankRef); } // Update file sizes bankRef.FileSizes.Clear(); if (Settings.Instance.HasPlatforms) { for (int i = 0; i < bankPlatforms.Length; i++) { string platformBankPath = Path.Combine(bankFolders[i], bankFileName); var fileInfo = new FileInfo(platformBankPath); if (fileInfo.Exists) { bankRef.FileSizes.Add(new EditorBankRef.NameValuePair(bankPlatforms[i], fileInfo.Length)); } } } else { string platformBankPath = Path.Combine(EditorUtils.GetBankDirectory(), bankFileName); var fileInfo = new FileInfo(platformBankPath); if (fileInfo.Exists) { bankRef.FileSizes.Add(new EditorBankRef.NameValuePair("", fileInfo.Length)); } } if (masterBankFileNames.Contains(bankFileInfo.Name)) { if (!eventCache.MasterBanks.Exists(x => bankFileInfo.FullName == x.Path)) { eventCache.MasterBanks.Add(bankRef); } } } // Remove any stale entries from bank and event lists eventCache.EditorBanks.FindAll((x) => !x.Exists).ForEach(RemoveCacheBank); eventCache.EditorBanks.RemoveAll((x) => !x.Exists); eventCache.EditorEvents.RemoveAll((x) => x.Banks.Count == 0); OnCacheChange(); } finally { // Unload the strings banks loadedBanks.ForEach(x => x.unload()); AssetDatabase.StopAssetEditing(); } }
public static VeryAnimationRig GetVeryAnimationRig(GameObject gameObject) { return(ArrayUtility.Find(gameObject.GetComponentsInChildren <VeryAnimationRig>(true), x => x.name == AnimationRiggingRigName && x.transform.parent == gameObject.transform)); }
private static void HeaderGUI(Editor editor) { var type = editor.target.GetType(); if (type == MONO_SCRIPT_TYPE) { return; } using (new EditorGUILayout.HorizontalScope()) { var path = AssetDatabase.GetAssetPath(editor.target); var oldEnabled = GUI.enabled; GUI.enabled = !string.IsNullOrWhiteSpace(path); if (GUILayout.Button("Explorer")) { if (AssetDatabase.IsValidFolder(path)) { var dataPath = Application.dataPath; var startIndex = dataPath.Length - REMOVE_DATA_PATH_COUNT; dataPath = dataPath.Remove(startIndex, REMOVE_DATA_PATH_COUNT); Process.Start(dataPath + path); } else { EditorUtility.RevealInFinder(path); } } GUI.enabled = oldEnabled; if (GUILayout.Button("Lock")) { var tracker = ActiveEditorTracker.sharedTracker; tracker.isLocked = !tracker.isLocked; tracker.ForceRebuild(); } if (GUILayout.Button("Debug")) { var window = Resources.FindObjectsOfTypeAll <EditorWindow>(); var inspectorWindow = ArrayUtility.Find(window, c => c.GetType().Name == "InspectorWindow"); if (inspectorWindow == null) { return; } var inspectorType = inspectorWindow.GetType(); var tracker = ActiveEditorTracker.sharedTracker; var isNormal = tracker.inspectorMode == InspectorMode.Normal; var methodName = isNormal ? "SetDebug" : "SetNormal"; var attr = BindingFlags.NonPublic | BindingFlags.Instance; var methodInfo = inspectorType.GetMethod(methodName, attr); methodInfo?.Invoke(inspectorWindow, null); tracker.ForceRebuild(); } } }