public Sprite GetIcon(string label) { IconSetDef iconsInfo = Get(label); if (iconsInfo == null) { Debug.LogError("Unable to find icon named : " + label); return(null); } string sheetName = iconsInfo.Sheet; int ndx = iconsInfo.SheetOffset; // Icons are always compound resources, as the 0th resource is the texture, 1st is sprite if (ndx <= 0) { ndx = 1; } UnityEngine.Object obj = PT_Game.Resources.GetResource(sheetName, ndx); if (!(obj is Sprite)) { Dbg.LogError(string.Format("Object {0} is not a sprite is {1} instead", label, obj.GetType().ToString())); } return(obj as Sprite); }
public override bool BuildFrom(TableObjectBuilder tbuilder) { if (tbuilder == null) { Dbg.LogError("BuildFrom failed because given builder is null "); return(false); } WeaponDefBuilder builder = tbuilder as WeaponDefBuilder; if (builder == null) { Dbg.LogError("BuildFrom failed because given builder is apparently wrong type "); return(false); } Id = builder.NameId; MinDamage = builder.MinDamage; MaxDamage = builder.MaxDamage; WeaponAnimationType tmp; AnimType.TryParse <WeaponAnimationType>(builder.AnimationType, out tmp); MaxDot = builder.MaxDot; return(true); }
CoroutineHandle StartInternal(IEnumerator enumerator, Component attachTo, RoutineFlags flags = RoutineFlags.None) { if (enumerator == null) { throw new ArgumentNullException("routine"); } if (attachTo != null && !attachTo.gameObject.activeInHierarchy) { Dbg.LogError( attachTo, "Coroutine couldn't be started because the the game object '{0}' is inactive!", GarbageCache.GetName(attachTo.gameObject) ); return(new CoroutineHandle()); } var routine = new Routine( id: ++idCounter, flags: flags, enumerator: enumerator, attachedTo: attachTo ); bool started = Resolve(ref routine, cameFromPostRender: false); return(new CoroutineHandle( id: started?routine.id: 0 )); }
public void EndTurn() { Dbg.LogError("End turn"); _currentTeamNdx = (_currentTeamNdx + 1) % _teams.Count; // TODO tell everyone !?! }
public GameObject InstantiateFromResource(string path, Transform parent, Vector3 position, Quaternion rotation) { UnityEngine.Object o = (UnityEngine.Object)GetResource(path); if (o == null) { Dbg.LogError("CreateFromResource null ref. Cannot create for type "); return(null); } return(Instantiate(o, position, rotation, parent) as GameObject); }
protected override void AtEnable() { if (rend == null) { Dbg.LogError(this, "{0} did not have a renderer", this); enabled = false; return; } activeAnimators.Add(this); }
int ReleaseWidget(int widgetId, UN_Pool pool) { Widget widget = null; if (_widgets.TryGetValue(widgetId, out widget) == false) { Dbg.LogError("Invalid widget id!"); } else { _widgets.Remove(widgetId); pool.Release(widget.Visual); } return(-1); }
} // base combatants only carried over from match // --------------------------------------------------------------------------------------- /// <summary> /// Create pawns for each combatant and place them in the world /// </summary> public void PlaceCombatants(MT_Arena arena) // --------------------------------------------------------------------------------------- { for (int i = 0; i < Combatants.Count; i++) { MT_ArenaSpawnPoint sp = arena.GetUnusedSpawnPoint(TeamNdx); if (sp == null) { Dbg.LogError("Not enough spawn points for match! failure abounds!"); return; } sp.Used = true; Combatants[i].PlaceInArena(sp, arena.PawnRoot.transform); } }
public string[] LoadStringArrayFromTextAsset(string resourcePath, bool removeEmpty = true) { TextAsset ass = Resources.Load(resourcePath) as TextAsset; if (ass == null) { Dbg.LogError("Cannot load text asset named: " + resourcePath); return(null); } string[] splitFile = new string[] { "\r\n", "\r", "\n" }; string[] results = ass.text.Split(splitFile, removeEmpty ? StringSplitOptions.RemoveEmptyEntries : StringSplitOptions.None); Resources.UnloadAsset(ass); return(results); }
Widget GetWidget(int widgetId, UN_Pool pool) { Widget widget = null; if (widgetId < 0 || _widgets.TryGetValue(widgetId, out widget) == false) { if (widgetId >= 0) { Dbg.LogError("Invalid widget id! Making new widget"); } widget = new Widget(); widget.Id = ++_highestId; widget.Visual = pool.Acquire(); _widgets.Add(widget.Id, widget); } return(widget); }
public static IEnumerator LoadRoutine() { var www = new WWW("file://" + System.IO.Path.Combine(Application.streamingAssetsPath, "DonkeyKong.ogg")); if (!string.IsNullOrEmpty(www.error)) { Dbg.LogError(www.error); yield break; } var movie = www.movie; while (!movie.isReadyToPlay) { yield return(null); } texture = movie; }
public UnityEngine.Object GetResource(string path) { UnityEngine.Object res; if (_resources.TryGetValue(path, out res)) { return(res); } res = Resources.Load(path); if (res == null) { Dbg.LogError("Failed to load resource at path " + path); return(null); } else { _resources.Add(path, res); return(res); } }
public UnityEngine.Object GetResource(string path, int ndx) { UnityEngine.Object[] res; if (_compoundResources.TryGetValue(path, out res) == false) { res = Resources.LoadAll(path); if (res != null) { _compoundResources.Add(path, res); } } if (res == null) { Dbg.LogError("Failed to find or load resource at path " + path); return(null); } return(res[ndx]); }
void FindAndSetupState() { // Start off just picking a sibling component // if present currentAppState = GetComponent <AppState>(); // Then find all in the scene AppState[] statesInScene = FindObjectsOfType <AppState>(); // If a state is found that is not the sibling // prioritize that one for (int i = 0; i < statesInScene.Length; ++i) { var state = statesInScene[i]; if (state != currentAppState) { currentAppState = state; break; } } if (currentAppState == null) { Dbg.LogError(this, "APP: Unable to find an AppState in scene or as sibling component"); return; } Dbg.Log(this, "APP: Starting with state {0}", currentAppState); if (currentAppState.transform != transform) { currentAppState.transform.parent = transform; } PreinitializeState(currentAppState); currentAppState.AtSetup(); }
GameObject InstantiateSelf(List <GameObject> previouslyInstantiated) { if (instantiated != null) { return(instantiated); } if (prefab == null) { return(null); } if (previouslyInstantiated.Contains(prefab)) { Dbg.LogError( this, "{0} was already instantiated in this hierarchy. It will not be instantiated to avoid recursion.", this ); return(null); } if (prefab == gameObject) { Dbg.LogError( this, "{0} had itself as prefab. It will not be instantiated to avoid recursion.", this ); return(null); } #if UNITY_EDITOR if (EditorApplication.isPlayingOrWillChangePlaymode) { instantiated = GameObject.Instantiate(prefab); } else { instantiated = PrefabUtility.InstantiatePrefab( prefab, destinationScene: gameObject.scene ) as GameObject; } #else instantiated = GameObject.Instantiate(prefab); #endif // UNITY_EDITOR var instantiatedTrans = instantiated.transform; if (instantiated != null) { Vector3 position = instantiatedTrans.localPosition; Quaternion rotation = instantiatedTrans.localRotation; Vector3 scale = instantiatedTrans.localScale; instantiated.transform.parent = transform; instantiated.transform.localPosition = position; instantiated.transform.localRotation = rotation; instantiated.transform.localScale = scale; } instantiated.name = prefab.name; return(instantiated); }