Exemplo n.º 1
0
        private void Awake()
        {
            _gameScenarioBase = FindObjectOfType <GameScenarioBase>();
            _gameProgress     = FindObjectOfType <GameProgress>();

            _nextSceneNumber = SceneManager.GetActiveScene().buildIndex + _nextLoadSceneNumber;
            if (_gameScenarioBase == null)
            {
                var scenario = CustomResources.Load <GameScenarioBase>
                                   (AssetsPathGameObject.GameObjects[GameObjectType.GameScenarioExecutor]);

                _gameScenarioBase = Instantiate(scenario);
                if (_gameScenarioBase == null)
                {
                    CustomDebug.LogError("GameScenarioExecutor has no scenario", this);
                    return;
                }
            }
            _gameScenarioBase.Inject(_gameProgress);

            Planner.Chain()
            .AddFunc(_gameScenarioBase.ExecuteScenario)
            .AddAction(LoadNextScene)
            ;
        }
Exemplo n.º 2
0
        public static void GetLoopOrder(tk2dTileMapData.SortMethod sortMethod, int w, int h, out int x0, out int x1, out int dx, out int y0, out int y1, out int dy)
        {
            switch (sortMethod)
            {
            case tk2dTileMapData.SortMethod.BottomLeft:
                x0 = 0; x1 = w; dx = 1;
                y0 = 0; y1 = h; dy = 1;
                break;

            case tk2dTileMapData.SortMethod.BottomRight:
                x0 = w - 1; x1 = -1; dx = -1;
                y0 = 0; y1 = h; dy = 1;
                break;

            case tk2dTileMapData.SortMethod.TopLeft:
                x0 = 0; x1 = w; dx = 1;
                y0 = h - 1; y1 = -1; dy = -1;
                break;

            case tk2dTileMapData.SortMethod.TopRight:
                x0 = w - 1; x1 = -1; dx = -1;
                y0 = h - 1; y1 = -1; dy = -1;
                break;

            default:
                CustomDebug.LogError("Unhandled sort method");
                goto case tk2dTileMapData.SortMethod.BottomLeft;
            }
        }
    public static tk2dSpriteCollectionData GetDefaultSpriteCollection()
    {
        BuildLookupIndex(false);

        foreach (tk2dSpriteCollectionIndex indexEntry in allSpriteCollections)
        {
            if (!indexEntry.managedSpriteCollection && indexEntry.spriteNames != null)
            {
                foreach (string name in indexEntry.spriteNames)
                {
                    if (name != null && name.Length > 0)
                    {
                        GameObject scgo = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(indexEntry.spriteCollectionDataGUID), typeof(GameObject)) as GameObject;
                        if (scgo != null)
                        {
                            return(scgo.GetComponent <tk2dSpriteCollectionData>());
                        }
                    }
                }
            }
        }

        CustomDebug.LogError("Unable to find any sprite collections.");
        return(null);
    }
Exemplo n.º 4
0
 /// <summary>
 /// Copies the source animation clip into the current one.
 /// All frames are duplicated.
 /// </summary>
 public void CopyFrom(tk2dSpriteAnimationClip source)
 {
     name = source.name;
     if (source.frames == null)
     {
         frames = null;
     }
     else
     {
         frames = new tk2dSpriteAnimationFrame[source.frames.Length];
         for (int i = 0; i < frames.Length; ++i)
         {
             if (source.frames[i] == null)
             {
                 frames[i] = null;
             }
             else
             {
                 frames[i] = new tk2dSpriteAnimationFrame();
                 frames[i].CopyFrom(source.frames[i]);
             }
         }
     }
     fps       = source.fps;
     loopStart = source.loopStart;
     wrapMode  = source.wrapMode;
     if (wrapMode == tk2dSpriteAnimationClip.WrapMode.Single && frames.Length > 1)
     {
         frames = new tk2dSpriteAnimationFrame[] { frames[0] };
         CustomDebug.LogError(string.Format("Clip: '{0}' Fixed up frames for WrapMode.Single", name));
     }
 }
Exemplo n.º 5
0
    void Init()
    {
        if (needMaterialInstance)
        {
            if (spriteCollection)
            {
                tk2dSpriteCollectionData spriteCollectionInst = spriteCollection.inst;
                for (int i = 0; i < spriteCollectionInst.materials.Length; ++i)
                {
                    if (spriteCollectionInst.materials[i] == material)
                    {
                        materialInst = spriteCollectionInst.materialInsts[i];
                        break;
                    }
                }

#if !UNITY_EDITOR
                if (materialInst == null)
                {
                    CustomDebug.LogError("Fatal error - font from sprite collection is has an invalid material");
                }
#endif
            }
            else
            {
                materialInst           = Instantiate(material) as Material;
                materialInst.hideFlags = HideFlags.DontSave;
            }
        }
        else
        {
            materialInst = material;
        }
    }
    /// <summary>
    /// Sets the reference to a poolable object with the specified component.
    /// </summary>
    /// <param name="componentOfPoolableObject">The component of the poolable object.</param>
    /// <param name="allowNonePoolable">If set to false an error is output if the object does not have the <see cref="PoolableObject"/> component.</param>
    public void Set(T componentOfPoolableObject, bool allowNonePoolable)
#endif
    {
        if (!componentOfPoolableObject)
        {
            Reset();
            return;
        }
        _objComponent = ( T )componentOfPoolableObject;
        _pooledObj    = _objComponent.GetComponent <PoolableObject>();
        if (!_pooledObj)
        {
            if (allowNonePoolable)
            {
                _initialUsageCount = 0;
            }
            else
            {
                CustomDebug.LogError("Object for PoolableReference must be poolable");
                return;
            }
        }
        else
        {
            _initialUsageCount = _pooledObj._usageCount;
        }
    }
Exemplo n.º 7
0
    protected virtual void HideTweenData(bool immediately, float delay)
    {
        for (int i = 0, n = tweensData.Count; i < n; i++)
        {
            TweenData t = tweensData[i];

            if (t != null)
            {
                if (t.tween == null)
                {
                    CustomDebug.LogError(gameObject.name + ": Tween on GUIControl component not set!", this);
                }
                else
                {
                    if (immediately)
                    {
                        t.tween.SetBeginStateImmediately();
                        t.tween.enabled = false;
                    }
                    else
                    {
                        t.tween.scaleDuration = t.hideDurationScale;
                        t.tween.SetBeginState(t.hideDelay + Random.Range(-t.showDelayVariance * 0.5f, t.showDelayVariance * 0.5f) + delay);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Internal function to make sure all material Ids are valid. Used in the tilemap editor
    /// </summary>
    public void InitMaterialIds()
    {
        if (inst.materialIdsValid)
        {
            return;
        }

        int firstValidIndex = -1;
        Dictionary <Material, int> materialLookupDict = new Dictionary <Material, int>();

        for (int i = 0; i < inst.materials.Length; ++i)
        {
            if (firstValidIndex == -1 && inst.materials[i] != null)
            {
                firstValidIndex = i;
            }
            materialLookupDict[materials[i]] = i;
        }
        if (firstValidIndex == -1)
        {
            CustomDebug.LogError("Init material ids failed.");
        }
        else
        {
            foreach (var v in inst.spriteDefinitions)
            {
                if (!materialLookupDict.TryGetValue(v.material, out v.materialId))
                {
                    v.materialId = firstValidIndex;
                }
            }
            inst.materialIdsValid = true;
        }
    }
Exemplo n.º 9
0
	/// <summary>
	/// Makes the text mesh pixel perfect to the active camera.
	/// Automatically detects <see cref="tk2dCamera"/> if present
	/// Otherwise uses Camera.main
	/// </summary>
	public void MakePixelPerfect()
	{
		float s = 1.0f;
		tk2dCamera cam = tk2dCamera.CameraForLayer(gameObject.layer);
		if (cam != null)
		{
			if (FontInst.version < 1)
			{
				CustomDebug.LogError("Need to rebuild font.");
			}

			float zdist = (transform.position.z - cam.transform.position.z);
			float textMeshSize = (FontInst.invOrthoSize * FontInst.halfTargetHeight);
			s = cam.GetSizeAtDistance(zdist) * textMeshSize;
		}
		else if (Camera.main)
		{
#if UNITY_5
			if (Camera.main.orthographic)
#else
			if (Camera.main.isOrthoGraphic)
#endif

			{
				s = Camera.main.orthographicSize;
			}
			else
			{
				float zdist = (transform.position.z - Camera.main.transform.position.z);
				s = tk2dPixelPerfectHelper.CalculateScaleForPerspectiveCamera(Camera.main.fieldOfView, zdist);
			}
			s *= FontInst.invOrthoSize;
		}
		scale = new Vector3(Mathf.Sign(scale.x) * s, Mathf.Sign(scale.y) * s, Mathf.Sign(scale.z) * s);
	}	
Exemplo n.º 10
0
    public static void ValidateMesh(Mesh mesh)
    {
                #if UNITY_EDITOR
        if (mesh != null)
        {
            if (!mesh.isReadable)
            {
                string path = UnityEditor.AssetDatabase.GetAssetPath(mesh);
                UnityEditor.ModelImporter mImporter = UnityEditor.AssetImporter.GetAtPath(path) as UnityEditor.ModelImporter;
                mImporter.isReadable = true;
                UnityEditor.AssetDatabase.ImportAsset(path, UnityEditor.ImportAssetOptions.ForceUpdate);
            }

            bool      outOfRange = false;
            Vector2[] uv1        = mesh.uv;
            for (int i = uv1.Length - 1; i >= 0 && !outOfRange; i--)
            {
                Vector2 v = uv1[i];
                outOfRange = (v.x < 0) || (v.x > 1f) || (v.y < 0) || (v.y > 1f);
                if (outOfRange)
                {
                    CustomDebug.LogError("WRONG MESH UV : " + "(" + v.x + " : " + v.y + ")" + " : " + mesh.name);
                }
            }

            if (outOfRange)
            {
                CustomDebug.LogError("WRONG MESH UV : " + UnityEditor.AssetDatabase.GetAssetPath(mesh) + "/" + mesh.name);
            }
        }
                #endif
    }
Exemplo n.º 11
0
    tk2dUIItem RaycastForUIItem(Vector2 screenPos)
    {
        int cameraCount = sortedCameras.Count;

        for (int i = 0; i < cameraCount; ++i)
        {
            tk2dUICamera currCamera = sortedCameras[i];
            if (currCamera.RaycastType == tk2dUICamera.tk2dRaycastType.Physics3D)
            {
                ray = currCamera.HostCamera.ScreenPointToRay(screenPos);
                if (Physics.Raycast(ray, out hit, currCamera.HostCamera.farClipPlane - currCamera.HostCamera.nearClipPlane, currCamera.FilteredMask))
                {
                    return(hit.collider.GetComponent <tk2dUIItem>());
                }
            }
            else if (currCamera.RaycastType == tk2dUICamera.tk2dRaycastType.Physics2D)
            {
#if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
                Collider2D collider = Physics2D.OverlapPoint(currCamera.HostCamera.ScreenToWorldPoint(screenPos), currCamera.FilteredMask);
                if (collider != null)
                {
                    return(collider.GetComponent <tk2dUIItem>());
                }
#else
                CustomDebug.LogError("Physics2D only supported in Unity 4.3 and above");
#endif
            }
        }
        return(null);
    }
    private bool TryAddNewPair(PropertyWrapper wrapper, SerializedProperty newKey)
    {
        bool suchKeyExists = false;

        for (int i = 0; i < wrapper.Count; i++)
        {
            var curKey = wrapper.GetKeyAtIndex(i);
            if (Holder.KeysAreEqual(curKey, newKey))
            {
                suchKeyExists = true;
            }
        }

        if (!suchKeyExists)
        {
            int curSize = wrapper.Count;
            wrapper.InsertPairAtIndex(curSize);
            Holder.PutValue(wrapper.GetKeyAtIndex(curSize));
            wrapper.Apply();
            return(true);
        }
        else
        {
            CustomDebug.LogError("Key already exists " + newKey.ToString());
            return(false);
        }
    }
Exemplo n.º 13
0
    protected override void Awake()
    {
        base.Awake();
        gameObject.GetComponentsInChildren <ObjectPool>(pools);

                #if UNITY_EDITOR
        pools.Sort
        (
            (a, b) => string.CompareOrdinal(a.name, b.name)
        );
                #endif

        foreach (ObjectPool pool in pools)
        {
            if (pool.prefab == null)
            {
                CustomDebug.LogError("Missing prefab in pool : " + pool.name, pool);
            }
            else
            {
                if (!poolMap.ContainsKey(pool.prefab.name))
                {
                    poolMap.Add(pool.prefab.name, pool);
                }
                else
                {
                    CustomDebug.LogError("Duplicate : " + pool.prefab.name, pool);
                }
            }
        }
    }
Exemplo n.º 14
0
    static Texture2D LoadTextureEditor(string imagePath, bool doMipMaps)
    {
        Texture2D resultTexture = new Texture2D(4, 4, TextureFormat.RGBA32, doMipMaps);

        byte[] curImageBytes = null;
        if (File.Exists(imagePath))
        {
            curImageBytes = File.ReadAllBytes(imagePath);
        }
        else
        {
            resultTexture = null;
            CustomDebug.LogError("File <" + imagePath + "> does not exist");
        }

        if (curImageBytes == null || !resultTexture.LoadImage(curImageBytes))
        {
            if (curImageBytes == null)
            {
                CustomDebug.LogError("Image bytes is null");
            }
            else
            {
                CustomDebug.Log("Can't load image");
            }
            resultTexture = null;
        }

        return(resultTexture);
    }
Exemplo n.º 15
0
    // Deletes the asset from the global asset dictionary
    // and removes the associated the asset from the build
    public static bool UnmakeLoadableAsset(Object obj)
    {
        string guid = GetObjectGUID(obj);
        List <tk2dResourceTocEntry> toc = new List <tk2dResourceTocEntry>(tk2dSystem.inst.Editor__Toc);

        foreach (tk2dResourceTocEntry entry in toc)
        {
            if (entry.assetGUID == guid)
            {
                // Delete the corresponding resource object
                string resourceObjectPath = AssetDatabase.GUIDToAssetPath(entry.resourceGUID);
                AssetDatabase.DeleteAsset(resourceObjectPath);

                // remove from TOC
                toc.Remove(entry);
                break;
            }
        }

        if (tk2dSystem.inst.Editor__Toc.Length == toc.Count)
        {
            CustomDebug.LogError("tk2dSystem.UnmakeLoadableAsset - Unable to delete asset");
            return(false);
        }
        else
        {
            tk2dSystem.inst.Editor__Toc = toc.ToArray();
            EditorUtility.SetDirty(tk2dSystem.inst);
            AssetDatabase.SaveAssets();

            return(true);
        }
    }
Exemplo n.º 16
0
    public static Dictionary <string, NestedPrefab> CollectGUIDMap(string filter, List <GameObject> duplicates = null)
    {
        Dictionary <string, NestedPrefab> map = new Dictionary <string, NestedPrefab>();
        List <NestedPrefab> prefabs           = AssetUtility.GetAssetsAtPath <NestedPrefab>(filter);

        foreach (NestedPrefab p in prefabs)
        {
            if (!p.IsNull())
            {
                if (!map.ContainsKey(p.prefabGuid))
                {
                    map.Add(p.prefabGuid, p);
                }
                else
                {
                    if (duplicates != null)
                    {
                        duplicates.Add(p.gameObject);
                    }

                    CustomDebug.LogError("NestedPrefab: Duplicate GUID pair :  " + p.name + "   +   " + map[p.prefabGuid].name);

                    p.GenerateNewGUID();
                    EditorUtility.SetDirty(p);
                    map.Add(p.prefabGuid, p);

                    CustomDebug.LogError("NestedPrefab: Rebuid GUID for " + p.name, p.gameObject);
                }
            }
        }

        return(map);
    }
Exemplo n.º 17
0
    IEnumerator Loading(string path)
    {
        WWW loader = new WWW(path);

        yield return(loader);

        state = TextureState.NotLoaded;

        if (loader.isDone)
        {
            if (string.IsNullOrEmpty(loader.error))
            {
                texture = loader.textureNonReadable;
                state   = TextureState.Loaded;
            }
            else
            {
                CustomDebug.LogError("Can't download texture by url : " + path + "\n" + loader.error);
            }
        }

        loader.Dispose();
        loading = null;

        if (!callbacks.Call(path, texture))
        {
            UnloadTexture();
        }
    }
Exemplo n.º 18
0
    static internal void _UnregisterType(IRegisteredComponent component, Type type)
    {
        InstanceContainer container = _GetInstanceContainer(type);

        if (!container.Remove(component))
        {
            CustomDebug.LogError("RegisteredComponentController error: Tried to unregister unknown instance");
        }
    }
Exemplo n.º 19
0
        static public T GetSingleton(bool autoCreate)
        {
            if (!instanceT)   // Unity operator to check if object was destroyed,
            {
                T component = null;

                #if UNITY_EDITOR
                if ((Application.isPlaying) && (!UnityEditor.EditorApplication.isPaused))
                {
                    var components = GameObject.FindObjectsOfType <T>();

                    foreach (var c in components)
                    {
                        var singletonCpt = (ISingletonMonoBehaviour)(c);
                        if (singletonCpt.IsSingletonObject)
                        {
                            component = c;
                            CustomDebug.LogError("Must call base.Awake() singleton : " + typeT.Name);
                            break;
                        }
                    }
                }
                #endif

                if (!component)
                {
                    if (autoCreate
                        #if UNITY_EDITOR
                        && Application.isPlaying &&
                        !UnityEditor.EditorApplication.isPaused
                        #endif
                        && !destroySingletonCalled
                        )
                    {
                        GameObject go = new GameObject(typeT.Name, new Type[] { typeT });
                        go.transform.parent = AutocreateRoot;

                        CustomDebug.LogWarning("Create singleton : " + typeT.Name);

                        component = go.GetComponent <T>();
                        if (component == null)
                        {
                            CustomDebug.LogError("Auto created object does not have component " + typeT.Name);
                            component = null;
                        }
                    }
                    else
                    {
                        component = null;
                    }
                }

                instanceT = component;
            }

            return(instanceT);
        }
Exemplo n.º 20
0
    static private void _RegisterType(IRegisteredComponent component, Type type)
    {
        InstanceContainer container = _GetInstanceContainer(type);

        if (!container.Add(component))
        {
            CustomDebug.LogError("RegisteredComponentController error: Tried to register same instance twice");
        }
    }
Exemplo n.º 21
0
    public override Texture2D Load(string path, TextureFormat format, bool mipmaps)
    {
        if (state != TextureState.Loaded)
        {
            CustomDebug.LogError("TextureProviderWWW.Load : cant load instatly from WWW");
        }

        return(texture);
    }
Exemplo n.º 22
0
    public void RepositionForCell(LayoutCellInfo info)
    {
        if (ButtonCollider == null)
        {
            CustomDebug.LogError("Collider not set !");
            return;
        }

        ButtonCollider.size = new Vector3(info.cellRect.width * xCoof, info.cellRect.height * yCoof, 1f);
    }
Exemplo n.º 23
0
    static void DoCreateCameraObject()
    {
        bool setAsMain = (Camera.main == null);

        Camera[] allCameras = Object.FindObjectsOfType(typeof(Camera)) as Camera[];
        foreach (Camera cam in allCameras)
        {
            if (cam.cullingMask == -1)
            {
                CustomDebug.LogError(string.Format("Camera: {0} has Culling Mask set to Everything. This will cause the scene to be drawn multiple times. Did you mean to do this?", cam.name));
            }
        }

        GameObject go = tk2dEditorUtility.CreateGameObjectInScene("tk2dCamera");

#if UNITY_3_5
        go.active = false;
#else
        go.SetActive(false);
#endif
        go.transform.position = new Vector3(0, 0, -10.0f);
        Camera camera = go.AddComponent <Camera>();
        camera.orthographic     = true;
        camera.orthographicSize = 480.0f;         // arbitrary large number
        camera.farClipPlane     = 1000.0f;
        camera.hideFlags        = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
        tk2dCamera newCamera = go.AddComponent <tk2dCamera>();
        newCamera.version = 1;
        #if UNITY_5_6_OR_NEWER
        go.AddComponent <FlareLayer>();
        #else
        go.AddComponent("FlareLayer");
        #endif
        go.AddComponent <GUILayer>();
        if (Object.FindObjectsOfType(typeof(AudioListener)).Length == 0)
        {
            go.AddComponent <AudioListener>();
        }

#if UNITY_3_5
        go.active = true;
#else
        go.SetActive(true);
#endif


        // Set as main camera if Camera.main is not set
        if (setAsMain)
        {
            go.tag = "MainCamera";
        }

        Selection.activeGameObject = go;
        Undo.RegisterCreatedObjectUndo(go, "Create tk2dCamera");
    }
Exemplo n.º 24
0
    static void Parse()
    {
        if (!isParse)
        {
            string filePath  = Application.streamingAssetsPath + "/guids";
            string result    = string.Empty;
            bool   isCorrect = false;

            float time = Time.realtimeSinceStartup;

            if (filePath.Contains(PathUtils.WWW_FILE_PREFIX))
            {
                using (WWW wwwFile = new WWW(filePath))
                {
                    while (!wwwFile.isDone)
                    {
                        System.Threading.Thread.Sleep(1);
                    }
                    isCorrect = string.IsNullOrEmpty(wwwFile.error);
                    if (isCorrect)
                    {
                        result = wwwFile.text;
                    }
                }
            }
            else
            {
                isCorrect = File.Exists(filePath);
                if (isCorrect)
                {
                    result = System.IO.File.ReadAllText(filePath);
                }
            }

            if (isCorrect)
            {
                string[] paths = result.Split(new string[] { System.Environment.NewLine }, System.StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0, pathsLength = paths.Length; i < pathsLength; i++)
                {
                    var    line = paths[i];
                    string guid = line.Substring(0, GUID_LENGTH);
                    string path = line.Substring(GUID_LENGTH, line.Length - GUID_LENGTH);
                    guidMap.Add(guid, path);
                }

                time = (Time.realtimeSinceStartup - time) * 1000;
                CustomDebug.Log("GUIDMapper.Parse by : " + time.ToString("f10") + " miliseconds for " + guidMap.Keys.Count);
            }
            else
            {
                CustomDebug.LogError("GUIDMapper.Error can't find file : " + filePath);
            }
            isParse = true;
        }
    }
Exemplo n.º 25
0
    void Start()
    {
        if (tk2dUIManager.Instance == null)
        {
            CustomDebug.LogError("Unable to find tk2dUIManager. Please create a tk2dUIManager in the scene before proceeding.");
        }

        if (isChildOfAnotherUIItem && parentUIItem == null)
        {
            UpdateParent();
        }
    }
Exemplo n.º 26
0
    static void AddSpriteCollectionFromIndex(tk2dSpriteCollectionIndex indexEntry)
    {
        string path = AssetDatabase.GUIDToAssetPath(indexEntry.spriteCollectionDataGUID);
        tk2dSpriteCollectionData data = AssetDatabase.LoadAssetAtPath(path, typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;

        if (data == null)
        {
            CustomDebug.LogError(string.Format("Unable to load sprite collection '{0}' at path '{1}'", indexEntry.name, path));
            return;
        }
        MakeLoadableAsset(data, indexEntry.managedSpriteCollection ? " " : data.assetName);
        data = null;
    }
Exemplo n.º 27
0
    static void AddFontFromIndex(tk2dGenericIndexItem indexEntry)
    {
        string       path = AssetDatabase.GUIDToAssetPath(indexEntry.dataGUID);
        tk2dFontData data = AssetDatabase.LoadAssetAtPath(path, typeof(tk2dFontData)) as tk2dFontData;

        if (data == null)
        {
            CustomDebug.LogError(string.Format("Unable to load font data '{0}' at path '{1}'", indexEntry.AssetName, path));
            return;
        }
        MakeLoadableAsset(data, "");         // can't make it directly loadable, hence no asset name
        data = null;
    }
Exemplo n.º 28
0
    /// <summary>
    /// Adds a tk2dBaseSprite derived class as a component to the gameObject passed in, setting up necessary parameters
    /// and building geometry. Shorthand using sprite name
    /// </summary>
    public static T AddComponent <T>(GameObject go, tk2dSpriteCollectionData spriteCollection, string spriteName) where T : tk2dBaseSprite
    {
        int spriteId = spriteCollection.GetSpriteIdByName(spriteName, -1);

        if (spriteId == -1)
        {
            CustomDebug.LogError(string.Format("Unable to find sprite named {0} in sprite collection {1}", spriteName, spriteCollection.spriteCollectionName));
            return(null);
        }
        else
        {
            return(AddComponent <T>(go, spriteCollection, spriteId));
        }
    }
Exemplo n.º 29
0
    /// <summary>
    /// Sets sprite by name from the new collection.
    /// </summary>
    public bool SetSprite(tk2dSpriteCollectionData newCollection, string spriteName)
    {
        int spriteId = newCollection.GetSpriteIdByName(spriteName, -1);

        if (spriteId != -1)
        {
            SetSprite(newCollection, spriteId);
        }
        else
        {
            CustomDebug.LogError("SetSprite - Sprite not found in collection: " + spriteName);
        }
        return(spriteId != -1);
    }
Exemplo n.º 30
0
    void Start()
    {
        if (uiCamera != null)
        {
            CustomDebug.Log("It is no longer necessary to hook up a camera to the tk2dUIManager. You can simply attach a tk2dUICamera script to the cameras that interact with UI.");
            HookUpLegacyCamera(uiCamera);
            uiCamera = null;
        }

        if (allCameras.Count == 0)
        {
            CustomDebug.LogError("Unable to find any tk2dUICameras, and no cameras are connected to the tk2dUIManager. You will not be able to interact with the UI.");
        }
    }