public object InsertAsset(AssetReq Req) { try { //AssetsDBEntities DB=new AssetsDBEntities(); Request_assets R = new Request_assets(); if (R.RequestID == 0) { R.AssetName = Req.AssetName; R.Quantity = Req.Quantity; R.EmployeID = Req.EmployeID; R.Status = "Pending"; R.MgrID = Req.MgrID; DB.Request_assets.Add(R); DB.SaveChanges(); return(new Response { Status = "Success", Message = "Record SuccessFully Saved." }); } } catch (Exception) { throw; } return(new Response { Status = "Error", Message = "Invalid Data." }); }
public object UpdateRequest(AssetReq AA) { try { Request_assets R = new Request_assets(); var obj = DB.Request_assets.Where(z => z.RequestID == AA.RequestID).ToList().FirstOrDefault(); //int x; if (obj.RequestID > 0) { obj.AssetName = AA.AssetName; obj.Quantity = AA.Quantity; obj.EmployeID = AA.EmployeID; obj.Status = AA.Status; obj.MgrID = AA.MgrID; DB.SaveChanges(); return(new Response { Status = "Success", Message = "Asset SuccessFully Updated." }); } } catch (Exception) { throw; } return(new Response { Status = "Error", Message = "Invalid Data." }); }
public object UpdateRequest(AssetReq AA) { try { Request_Assets RA = new Request_Assets(); var obj = DB.Request_Assets.Where(z => z.RequestID == AA.RequestID).ToList().FirstOrDefault(); if (obj.RequestID > 0) { obj.Status = AA.Status; DB.SaveChanges(); return(new Response { Status = "Success", Message = "Asset SuccessFully Updated." }); } } catch (Exception) { throw; } return(new Response { Status = "Error", Message = "Invalid Data." }); }
public AssetReq AddReq(string pathName, Vector3 position, Quaternion rotation, Vector3 scale) { AssetReq req = new AssetReq(pathName, new AssetPRS(position, rotation, scale)); AddReq(req); return(req); }
public void AddReq(AssetReq request) { if (request.PathName.Length < MinValidPathLen) { return; } assetStack_Request.Push(request); }
public virtual void Build() { if (string.IsNullOrEmpty(prefabPath) || null != mViewPrefab || null != mPrefabReq) { return; } mPrefabReq = AssetsLoader.Instance.AddReq(m_PrefabPath, Entity.peTrans.position, Entity.peTrans.rotation, Vector3.one); mPrefabReq.ReqFinishHandler += OnBoneLoad; }
public override bool Equals(object obj) { AssetReq other = obj as AssetReq; if (other == null) { return(false); } return(PathName.Equals(other.PathName) && Prs.Equals(other.Prs)); }
void Start() // could use IEnumerator to create _airborneGo async { string path = _type == Type.Puja ? "Item/scene_puja_aircraft.unity3d" : "Item/scene_paja_aircraft.unity3d"; AssetReq req = AssetsLoader.Instance.AddReq(path, Vector3.zero, Quaternion.identity, Vector3.one); req.ReqFinishHandler += StartAirborne; //GameObject airborneGo = AssetsLoader.Instance.AddReq(path, Vector3.zero, Quaternion.identity, Vector3.one); //StartAirborne(airborneGo); }
public void OnSpawned(GameObject go, AssetReq req) { foreach (CreateReq cReq in mCreateReqList) { if (cReq.mReq == req) { CreateMode(go, cReq); return; } } Destroy(go); }
public void OnSpawned(GameObject go, AssetReq req) { if (reqlist.ContainsKey(req)) { CreateWareHouse(go, reqlist[req]); reqlist.Remove(req); } else { Destroy(go); } }
public void OnSpawned(GameObject go, AssetReq req) { if (mReqList.ContainsKey(req)) { go.transform.parent = transform; go.transform.transform.localPosition = mReqList[req].mPos; go.transform.transform.localRotation = mReqList[req].mRotation; go.transform.transform.localScale = Vector3.one; mReqList.Remove(req); } else { Destroy(go); } }
IEnumerator SpawnAI() { while (count > 0) { yield return(new WaitForSeconds(interval)); if (active && IsRevisePosition()) { int id = pathIDs[Random.Range(0, pathIDs.Length)]; AssetReq req = AIResource.Instantiate(id, position, Quaternion.identity, OnSpawned); reqList.Add(req); count--; } } }
protected void TryLoadMainGo() { if (_pathMainAsset.Length > 0) { _bMainAssetLoading = true; if (_pathMainAsset.Contains(".unity3d")) { AssetPRS pos = new AssetPRS(_pos, _rot, _scl); AssetReq req = new AssetReq(_pathMainAsset, pos); AssetsLoader.Instance.AddReq(req); req.ReqFinishHandler += OnAssetLoaded; } else { GameObject go = GameObject.Instantiate(Resources.Load(_pathMainAsset), _pos, _rot) as GameObject; go.transform.localScale = _scl; OnAssetLoaded(go); } } }
public void Instantiate(int id, Vector3 pos, Quaternion rot) { Vector3 fixPosition = AIResource.FixedHeightOfAIResource(id, pos); if (GameConfig.IsMultiMode) { //AIGroupNetWork group = Netlayer as AIGroupNetWork; //if (null == group) // return; //uLink.NetworkViewID tdViewID = group.AiTD == null ? uLink.NetworkViewID.unassigned : group.AiTD.OwnerView.viewID; // IntVector4 _inx = new IntVector4(mIndex.x, mIndex.y, mIndex.z, curCount); //RPCServer(EPacketType.PT_AG_SpawnAIGroupMemberAtPoint, _inx, fixPosition, id, 2, tdViewID); } else { mSpawnedCount++; AssetReq req = AIResource.Instantiate(id, fixPosition, rot, OnSpawned); mReqs.Add(req); } }
protected virtual void OnBoneLoad(GameObject obj) { mPrefabReq = null; mViewPrefab = obj.transform; mViewPrefab.parent = Entity.GetGameObject().transform; mViewPrefab.position = Entity.peTrans.position; mViewPrefab.rotation = Entity.peTrans.rotation; mViewPrefab.localScale = Entity.peTrans.scale; biologyViewRoot = mViewPrefab.GetComponent <BiologyViewRoot>(); monoBoneCollector = mViewPrefab.GetComponent <WhiteCat.BoneCollector>(); if (null == biologyViewRoot) { // Some doodads haven't root, we add it to start coroutine and make coroutine stopable while destroying mViewPrefab //Debug.LogError("BiologyViewRoot not found in " + mViewPrefab.name); biologyViewRoot = mViewPrefab.gameObject.AddComponent <BiologyViewRoot>(); } biologyViewRoot.StartCoroutine(ProcPostBoneLoad()); }
//System.Diagnostics.Stopwatch _sw = new System.Diagnostics.Stopwatch(); IEnumerator ProcessReqs(Stack <AssetReq> assetReqList, string assetBundlePath) { while (true) { if (assetReqList.Count > 0) { AssetReq req = assetReqList.Pop(); if (req.ProcLevel <= AssetReq.ProcLvl.DoNothing) { continue; } /* test code for LoadAssetImm * GameObject goo = LoadAssetImm(req.pathName, req.pos.Position(), req.pos.Rotation(), req.pos.Scale()); * if(goo != null){ req.OnFinish(goo); } * yield return 0; * continue; */ //_sw.Reset(); //_sw.Start(); Object asset = null; string assetPathName = req.PathName; string assetPathNameExt = Path.GetExtension(req.PathName); bool bAssetBundle = assetPathNameExt.Equals(AssetBundleExtension); if (!bAssetBundle && !String.IsNullOrEmpty(assetPathNameExt)) { assetPathName = (Path.GetDirectoryName(req.PathName) + "/" + Path.GetFileNameWithoutExtension(req.PathName)); } if (!AssetsPool.TryGetAsset(assetPathName, out asset)) { if (bAssetBundle) { WWW www = WWW.LoadFromCacheOrDownload("file://" + assetBundlePath + assetPathName, AssetsPool.s_Version); yield return(www); if (www.error != null) { Debug.LogError(www.error); } else { AssetBundle assetBundle = www.assetBundle; AssetBundleRequest request = assetBundle.LoadAssetAsync(Path.GetFileNameWithoutExtension(assetPathName), typeof(GameObject)); yield return(request); if (request != null) { asset = request.asset; } request = null; assetBundle.Unload(false); } if (www != null) { www.Dispose(); www = null; } } else // Treat as prefab { #if UNITY_EDITOR if (assetPathName.StartsWith("../")) { asset = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/" + req.PathName.Substring(3), typeof(GameObject)); } else #endif { #if UNITY_EDITOR //Debug.LogError("Load uncached prefab :"+assetPathName); #endif ResourceRequest resReq = Resources.LoadAsync(assetPathName); while (!resReq.isDone) { yield return(null); } asset = resReq.asset; } } if (asset != null && req.NeedCaching) { AssetsPool.RegisterAsset(assetPathName, asset); } } //_sw.Stop(); //Debug.LogError("Load "+assetPathName+":"+_sw.ElapsedMilliseconds); if (asset != null && req.ProcLevel >= AssetReq.ProcLvl.DoInstantiation) { GameObject go = Instantiate(asset, req.Prs.Position(), req.Prs.Rotation()) as GameObject; if (go != null) { Profiler.BeginSample("AssetsLoader:Instantiate " + assetPathName); go.transform.localScale = req.Prs.Scale(); req.OnFinish(go); Profiler.EndSample(); } } } yield return(null); } }