// void Awake() { #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) { return; } #endif mInstance = this; int width = Screen.width > Screen.height ? Screen.width : Screen.height; bool hd = width > MaxWidth; CurrentAssetSuffix = hd ? AssetSuffix : ""; // Load the asset collection prefab string assetName = hd ? Asset2xName : DefaultAssetName; GameObject go = Resources.Load <GameObject>(assetName); if (go != null) { mActiveAsset = go.GetComponent <AssetCollection>(); mActiveAsset.Initialize(); } else { Debug.LogError("Multires: Load asset failed: " + assetName); } DebugPrint(); #if !UNITY_EDITOR DontDestroyOnLoad(this); #endif }
// void Awake() { #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) return; #endif mInstance = this; int width = Screen.width > Screen.height ? Screen.width : Screen.height; bool hd = width > MaxWidth; CurrentAssetSuffix = hd ? AssetSuffix : ""; // Load the asset collection prefab string assetName = hd ? Asset2xName : DefaultAssetName; GameObject go = Resources.Load<GameObject>(assetName); if (go != null) { mActiveAsset = go.GetComponent<AssetCollection>(); mActiveAsset.Initialize(); } else { Debug.LogError("Multires: Load asset failed: " + assetName); } DebugPrint(); #if !UNITY_EDITOR DontDestroyOnLoad(this); #endif }
public static Multires Create() { GameObject go; go = new GameObject(); go.name = "Multires"; return (mInstance = go.AddComponent<Multires>()); }
public static Multires Create() { GameObject go; go = new GameObject(); go.name = "Multires"; return(mInstance = go.AddComponent <Multires>()); }
/** * */ void Awake() { #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) { return; } #endif if (Multires.instance != null && !DisableSwapping) { if (SpriteName.Length > 0) { // Attemp to swap sprite SpriteRenderer spriteRend = GetComponent <SpriteRenderer>(); if (spriteRend != null) { Sprite sprite = Multires.GetSprite(SpriteName); if (sprite != null) { spriteRend.sprite = sprite; //Debug.Log("Relink sprite renderer: " + gameObject.name); } else { //Debug.LogWarning("Sprite not found: " + SpriteName + Multires.instance.CurrentAssetSuffix); } } } if (AnimationControllerName.Length > 0) { // Attempt to swap animation clip Animator animator = GetComponent <Animator>(); if (animator != null) { RuntimeAnimatorController controller = Multires.GetAnimatorController(AnimationControllerName); if (controller != null) { animator.runtimeAnimatorController = controller; //Debug.Log("Relink controller: " + gameObject.name); } else { //Debug.LogWarning("Controller not found: " + AnimationControllerName + Multires.instance.CurrentAssetSuffix); } } } } Destroy(this); //Debug.Log("Self destruct: " + gameObject.name); }