public static void autoLayout2D(Transform traRoot) { if (traRoot == null) { PPP.pppShow(); return; } int ManualWidth = 1280; //首先记录下你想要的屏幕分辨率的宽 int ManualHeight = 720; //记录下你想要的屏幕分辨率的高 //普通安卓的都是 1280*720的分辨率 var scaleOld = traRoot.localScale; var canvasScaler = getScaler(traRoot); if (canvasScaler == null) { PPP.pppShow(); return; } if (canvasScaler.screenMatchMode == CanvasScaler.ScreenMatchMode.Expand) { //然后得到当前屏幕的高宽比 和 你自定义需求的高宽比。通过判断他们的大小,来不同赋值 //*其中Convert.ToSingle()和 Convert.ToFloat() 来取得一个int类型的单精度浮点数(C#中没有 Convert.ToFloat() ); if (Convert.ToSingle(Screen.height) / Screen.width > Convert.ToSingle(ManualHeight) / ManualWidth) { //如果屏幕的高宽比大于自定义的高宽比 。则通过公式 ManualWidth * manualHeight = Screen.width * Screen.height; //来求得适应的 manualHeight ,用它待求出 实际高度与理想高度的比率 scale int manualHeight = Mathf.RoundToInt(Convert.ToSingle(ManualWidth) / Screen.width * Screen.height); var scaleY = manualHeight * 1.0f / ManualHeight; traRoot.transform.localScale = new Vector3(scaleOld.x, scaleOld.y * scaleY, 1f); } else if (Convert.ToSingle(Screen.height) / Screen.width < Convert.ToSingle(ManualHeight) / ManualWidth) { int manualWidth = Mathf.RoundToInt(Convert.ToSingle(ManualHeight) / Screen.height * Screen.width); var scaleX = manualWidth * 1.0f / ManualWidth; traRoot.transform.localScale = new Vector3(scaleOld.x * scaleX, scaleOld.y, 1f); } } else if (canvasScaler.screenMatchMode == CanvasScaler.ScreenMatchMode.MatchWidthOrHeight && canvasScaler.matchWidthOrHeight == 0) { //然后得到当前屏幕的高宽比 和 你自定义需求的高宽比。通过判断他们的大小,来不同赋值 //*其中Convert.ToSingle()和 Convert.ToFloat() 来取得一个int类型的单精度浮点数(C#中没有 Convert.ToFloat() ); if (Convert.ToSingle(Screen.height) / Screen.width > Convert.ToSingle(ManualHeight) / ManualWidth) { //如果屏幕的高宽比大于自定义的高宽比 。则通过公式 ManualWidth * manualHeight = Screen.width * Screen.height; //来求得适应的 manualHeight ,用它待求出 实际高度与理想高度的比率 scale int manualHeight = Mathf.RoundToInt(Convert.ToSingle(ManualWidth) / Screen.width * Screen.height); var scaleY = manualHeight * 1.0f / ManualHeight; traRoot.transform.localScale = new Vector3(scaleOld.x, scaleOld.y * scaleY, 1f); } else if (Convert.ToSingle(Screen.height) / Screen.width < Convert.ToSingle(ManualHeight) / ManualWidth) { int manualWidth = Mathf.RoundToInt(Convert.ToSingle(ManualHeight) / Screen.height * Screen.width); var scaleX = manualWidth * 1.0f / ManualWidth; traRoot.transform.localScale = new Vector3(scaleOld.x, scaleOld.y / scaleX, 1f); } } else { PPP.pppShow(); } }
public static object getPropertyOriginal(object obj, string strPropertyName) { var hashCodeObj = obj.GetHashCode(); if (dicProperty.ContainsKey(obj.GetHashCode()) == false) { dicProperty.Add(hashCodeObj, new Dictionary <string, object>()); } var type = obj.GetType(); var propertyInfo = type.GetProperty(strPropertyName); object ret = null; if (propertyInfo != null) { if (dicProperty[hashCodeObj].ContainsKey(strPropertyName)) { ret = dicProperty[hashCodeObj][strPropertyName]; } else { dicProperty[hashCodeObj].Add(strPropertyName, propertyInfo.GetValue(obj, null)); ret = propertyInfo.GetValue(obj, null); } } else { PPP.pppShow(); } return(ret); }
private void Update() { try { if (queue.Count != 0 && !IsDialogActive) { DialogParameter parameter = queue.Dequeue(); UIDialogBase activeDialog = LoadScene(parameter._strPath); // 去加载这个UI界面 if (activeDialog != null) { openedList.Add(activeDialog); // 加到openedList里 activeDialog.transform.SetAsLastSibling(); activeDialog.OnSceneActivated(parameter._paras); // 场景打开的时候,把参数传递进去 } else { PPP.pppShow(); } } if (tipsQueue.Count != 0) { DialogParameter parameter = tipsQueue.Dequeue(); UIDialogBase dialog = LoadScene(parameter._strPath); dialog.transform.SetAsLastSibling(); dialog.OnSceneActivated(parameter._paras); } } catch (Exception ex) { PPP.pppShow(true, ex.ToString()); } }
public static void setProperty(object obj, string strPropertyName, object value) { var hashCodeObj = obj.GetHashCode(); if (dicProperty.ContainsKey(hashCodeObj) == false) { dicProperty.Add(hashCodeObj, new Dictionary <string, object>()); } var type = obj.GetType(); var propertyInfo = type.GetProperty(strPropertyName); if (propertyInfo != null) { if (dicProperty[hashCodeObj].ContainsKey(strPropertyName) == false) { dicProperty[hashCodeObj].Add(strPropertyName, propertyInfo.GetValue(obj, null)); } propertyInfo.SetValue(obj, value, null); } else { PPP.pppShow(); } }
void checkName(Transform tra, System.Reflection.FieldInfo item) { if (tra == null) { return; } var strName = tra.name; var type = item.FieldType; if (type == typeof(Button)) { if (strName.StartsWith("btn") == false) { PPP.pppShow(true, this.name + ":" + strName + " 命名不规范,Button 以 btn 开头"); } } else if (type == typeof(Image)) { if (strName.StartsWith("img") == false) { PPP.pppShow(true, this.name + ":" + strName + " 命名不规范,Image 以 img 开头"); } } else if (type == typeof(Text)) { if (strName.StartsWith("txt") == false) { PPP.pppShow(true, this.name + ":" + strName + " 命名不规范,Text 以 txt 开头"); } } else if (type == typeof(Toggle)) { if (strName.StartsWith("tog") == false) { PPP.pppShow(true, this.name + ":" + strName + " 命名不规范,Toggle 以 tog 开头"); } } else if (type == typeof(Transform)) { if (strName.StartsWith("tra") == false) { PPP.pppShow(true, this.name + ":" + strName + " 命名不规范,Transform 以 tra 开头"); } } else if (type == typeof(GameObject)) { if (strName.StartsWith("obj") == false) { PPP.pppShow(true, this.name + ":" + strName + " 命名不规范,GameObject 以 obj 开头"); } } else if (type.BaseType == typeof(Array)) { if (strName.StartsWith("arr") == false) { PPP.pppShow(true, this.name + ":" + strName + " 命名不规范,数组 以 arr 开头"); } } }
static void Main(string[] args) { /* * Выбрать любой класс из предыдущих работ. * Добавить 2 события – с параметрами и без параметров. * Создать несколько объектов класса и назначить им различные обработчики событий: * ● Статический метод любого класса * ● Экземплярный метод собственного класса * ● Анонимный делегат * ● Лямбда-выражение * */ #region Create Object Kiosk BelsouzDryk = new Kiosk("БелСоюздрук", "Рокосовского", 300, 2); Kiosk BelsouzDryk1 = new Kiosk(); Kiosk BelsouzDryk2 = new Kiosk("БелСоюздрук", "Рокосовского", 300, 2); Kiosk BelsouzDryk3 = new Kiosk("БелСоюздрук", "Рокосовского", 400, 5); Kiosk BelsouzDryk5 = new Kiosk("БелСоюздрук", "Рокосовского", 300, 8); Kiosk BelsouzDryk6 = new Kiosk(); Kiosk BelsouzDryk7 = new Kiosk("БелСоюздрук", "Рокосовского", 300, 9); Kiosk BelsouzDryk8 = new Kiosk("БелСоюздрук", "Рокосовского", 400, 10); //List<Kiosk> arr_Kiosk = new List<Kiosk>() { BelsouzDryk8, BelsouzDryk, BelsouzDryk1, BelsouzDryk2, BelsouzDryk3, BelsouzDryk5, BelsouzDryk6, BelsouzDryk7 }; //Console.WriteLine(BelsouzDryk.Equals(BelsouzDryk2)); //Console.WriteLine(BelsouzDryk.Equals(BelsouzDryk1)); //Console.WriteLine(BelsouzDryk > BelsouzDryk3); #endregion //Console.WriteLine(BelsouzDryk); MyDelegate_Print dele_print = new MyDelegate_Print(BelsouzDryk.Print); MyDelegate_Print dele_print1 = new MyDelegate_Print(BelsouzDryk.Print); Kiosk.MethodStatic(BelsouzDryk); PPP aaPpp = Kiosk.MethodStatic; MyDelegate_Print dele_print2 = dele_print + dele_print1; dele_print2 = dele_print2 - dele_print1; dele_print2.Invoke(); //dele_print(); //Старый способ вызова делегата. dele_print.Invoke(); // Вызов делегата MyDelegate_return_int dele_return_int = new MyDelegate_return_int(BelsouzDryk.AveregeValue); dele_return_int.Invoke(30); int x = BelsouzDryk.AveregeValue(30); BelsouzDryk.Print(); Probe_int pro = (i, o) => { return(o.AveregeValue(i)); }; Probe_int pr = delegate(int rx, Kiosk o) { return(o.AveregeValue(rx)); }; //анонимный метод MyDelegate_Print anonim = delegate { Console.WriteLine("Анонимная функция"); }; anonim(); Console.ReadKey(); }
/// <summary> /// 加载UI界面 /// </summary> /// <param name="strPath"></param> /// <param name="paras"></param> public void PushDialog(string strPath, params object[] paras) { if (strPath == null || strPath.Length == 0) { PPP.pppShow(); return; } DialogParameter parameter = new DialogParameter(strPath, paras); queue.Enqueue(parameter); }
/// <summary> /// Used internally by SpawnPools to remove themseleves on Destroy(). /// Use PoolManager.DestroyPool() to destroy an entire SpawnPool GameObject. /// </summary> /// <param name="spawnPool"></param> internal bool Remove(SpawnPool spawnPool) { if (!this.ContainsKey(spawnPool.poolName)) { PPP.pppShow(true, string.Format("PoolManager: Unable to remove '{0}'. " + "Pool not in PoolManager", spawnPool.poolName)); return(false); } this._pools.Remove(spawnPool.poolName); return(true); }
/// <summary> /// Used internally by SpawnPools to add themseleves on Awake(). /// Use PoolManager.CreatePool() to create an entirely new SpawnPool GameObject /// </summary> /// <param name="spawnPool"></param> internal void Add(SpawnPool spawnPool) { // Don't let two pools with the same name be added. See error below for details if (this.ContainsKey(spawnPool.poolName)) { PPP.pppShow(true, string.Format("A pool with the name '{0}' already exists. " + "This should only happen if a SpawnPool with " + "this name is added to a scene twice.", spawnPool.poolName)); return; } this._pools.Add(spawnPool.poolName, spawnPool); }
public T findChild <T>(string strPath) { var child = transform.Find(strPath); if (child == null) { return(default(T)); } if (isUIClass(typeof(T)) == false) { PPP.pppShow(); return(default(T)); } return(child.gameObject.GetComponent <T>()); }
/// <summary> /// 立刻加载UI界面 /// </summary> /// <param name="strPath"></param> /// <param name="paras"></param> /// <returns></returns> public UIDialogBase PushDialogImmediately(string strPath, params object[] paras) { DialogParameter parameter = new DialogParameter(strPath, paras); UIDialogBase activeDialog = LoadScene(parameter._strPath); if (activeDialog == null) { PPP.pppShow(); return(null); } openedList.Add(activeDialog); activeDialog.transform.SetAsLastSibling(); activeDialog.OnSceneActivated(parameter._paras); return(activeDialog); }
public Component findChild(string strPath, Type type) { var child = transform.Find(strPath); if (child == null) { PPP.pppShow(); return(null); } if (isUIClass(type) == false) { PPP.pppShow(); return(null); } return(child.gameObject.GetComponent(type)); }
private void startAlgorithm_Click(object sender, EventArgs e) { if (importedPupils == null) { MessageBox.Show("Sie müssen erst Schüler importieren, bevor Sie sie zuweisen können", "Error", MessageBoxButtons.OK); return; } PPP ppp = new PPP(); ProjectManager.leftOvers = ppp.Assign(ProjectManager.projectDict.Values, importedPupils).ToList <Pupil>(); MessageBox.Show("Fertig. Sie können nun die Ergebnisse als Excel-Tabelle speichern.", "Fertig", MessageBoxButtons.OK); saveExcelDialog.FileOk += new CancelEventHandler(SaveExcelFile); saveExcelDialog.ShowDialog(); }
public bool Empty() { return((Left.Count() + Right.Count() + Up.Count() + Down.Count() + LP.Count() + MP.Count() + HP.Count() + PPP.Count() + LK.Count() + MK.Count() + HK.Count() + KKK.Count() + Clear.Count() ) == 0); }
/// <summary> /// Destroy an entire SpawnPool, including its GameObject and all children. /// You can also just destroy the GameObject directly to achieve the same result. /// This is really only here to make it easier when a reference isn't at hand. /// </summary> /// <param name="spawnPool"></param> public bool Destroy(string poolName) { // Use TryGetValue to avoid KeyNotFoundException. // This is faster than Contains() and then accessing the dictionary SpawnPool spawnPool; if (!this._pools.TryGetValue(poolName, out spawnPool)) { PPP.pppShow(true, string.Format("PoolManager: Unable to destroy '{0}'. Not in PoolManager", poolName)); return(false); } // The rest of the logic will be handled by OnDestroy() in SpawnPool UnityEngine.Object.Destroy(spawnPool.gameObject); return(true); }
public static void addButtonClickEffect(Button button) { if (button.transition == Selectable.Transition.ColorTint || button.transition == Selectable.Transition.None) { GameObject btn = button.gameObject; EventTriggerListener.Get(btn).onDown = (bt) => { bt.transform.DOKill(); bt.transform.DOScale(((Vector3)PPP.getPropertyOriginal(bt.transform, "localScale")) * 0.9f, 0.1f); }; EventTriggerListener.Get(btn).onUp = (bt) => { bt.transform.DOKill(); bt.transform.DOScale((Vector3)PPP.getPropertyOriginal(bt.transform, "localScale"), 0.1f); }; } }
public T getChildByName <T>(string name) { var traTemp = getChildByName(name); if (traTemp == null) { return(default(T)); } if (isUIClass(typeof(T)) == false) { PPP.pppShow(); return(default(T)); } if (typeof(T) == typeof(GameObject) || typeof(T) == typeof(Transform)) { PPP.pppShow(true, "该方法不能获取 GameObject Transform"); } return(traTemp.gameObject.GetComponent <T>()); }
/// <summary> /// Register this item with the pool at game start /// </summary> private void Start() { SpawnPool pool; if (!PoolManager.Pools.TryGetValue(this.poolName, out pool)) { string msg = "PreRuntimePoolItem Error ('{0}'): " + "No pool with the name '{1}' exists! Create one using the " + "PoolManager Inspector interface or PoolManager.CreatePool()." + "See the online docs for more information at " + "http://docs.poolmanager.path-o-logical.com"; PPP.pppShow(true,string.Format(msg, this.name, this.poolName)); return; } // Add this instance to a pool pool.Add(this.transform, this.prefabName, this.despawnOnStart, !this.doNotReparent); }
/// <summary> /// 加载UI界面 /// </summary> /// <param name="strPrefabePath"></param> /// <returns></returns> public UIDialogBase LoadScene(string strPrefabePath) { UIDialogBase dialog = FindInCache(strPrefabePath); if (dialog == null) { GameObject newSceneGameObject = Resources.Load <GameObject>(strPrefabePath); if (newSceneGameObject != null) { newSceneGameObject = UIUtils.AddChild(this.gameObject, newSceneGameObject); if (newSceneGameObject != null) { dialog = newSceneGameObject.GetComponent <UIDialogBase>(); if (dialog == null) { newSceneGameObject.name = newSceneGameObject.name.Replace("(Clone)", ""); dialog = PPPUIBase.addScript(newSceneGameObject, newSceneGameObject.name) as UIDialogBase; } if (dialog != null) { dialog.name = strPrefabePath; dialog.InitializeScene(); } } else { PPP.pppShow(true, "UISystem::LoadDialog() Failed to add new scene to parent UISystem with name: " + strPrefabePath); } } else { PPP.pppShow(true, "UISystem::LoadDialog() Failed to load new scene with name: " + strPrefabePath); } } return(dialog); }
public static GameObject AddChild(GameObject parent, string Path) { var pre = Resources.Load <GameObject> (Path); if (pre == null) { PPP.pppShow(); return(null); } GameObject go = GameObject.Instantiate(pre) as GameObject; if (go != null && parent != null) { Transform t = go.transform; t.SetParent(parent.transform); t.localPosition = Vector3.zero; t.localRotation = Quaternion.identity; t.localScale = Vector3.one; go.layer = parent.layer; } return(go); }
public override void OnClick(string str) { base.OnClick(str); switch (str) { case "btn_Head": OnClickHead(); break; case "btn_Sure": OnClickSure(); break; case "btn_Back": OnBackPressed(); break; default: PPP.pppShow(); break; } }
/// <summary> /// Creates a new GameObject with a SpawnPool Component which registers itself /// with the PoolManager.Pools dictionary. The SpawnPool can then be accessed /// directly via the return value of this function or by via the PoolManager.Pools /// dictionary using a 'key' (string : the name of the pool, SpawnPool.poolName). /// </summary> /// <param name="poolName"> /// The name for the new SpawnPool. The GameObject will have the word "Pool" /// Added at the end. /// </param> /// <returns>A reference to the new SpawnPool component</returns> public SpawnPool Create(string poolName) { // Cannot request a name with the word "Pool" in it. This would be a // rundundant naming convention and is a reserved word for GameObject // defaul naming string tmpPoolName; tmpPoolName = poolName.Replace("Pool", ""); if (tmpPoolName != poolName) // Warn if "Pool" was used in poolName { // Log a warning and continue on with the fixed name string msg = string.Format("'{0}' has the word 'Pool' in it. " + "This word is reserved for GameObject defaul naming. " + "The pool name has been changed to '{1}'", poolName, tmpPoolName); PPP.pppShow(true, msg); poolName = tmpPoolName; } if (this.ContainsKey(poolName)) { Debug.Log(string.Format("A pool with the name '{0}' already exists", poolName)); return(null); } // Add "Pool" to the end of the poolName to make a more user-friendly // GameObject name. This gets stripped back out in SpawnPool Awake() var groupGO = new GameObject(poolName + "Pool"); // Note: This will run Awake() to finish init and Add self-add the pool var spawnPool = groupGO.AddComponent <SpawnPool>(); return(spawnPool); }
/* Load the scene and return the instanced scene. Now by name! */ public UISceneBase LoadScene(string page, bool hideScene = false) { // Find the scene in the loaded list for (int idx = 0; idx < LoadedScenes.Count; idx++) { // NEW: find by name instead of enum if (LoadedScenes[idx] != null && LoadedScenes[idx].Page == page) { return(LoadedScenes[idx]); } } //if (page == UIPage.Null) //{ // PPP.pppShow(); // return null; //} string strPrefabeName = page; GameObject newSceneGameObject = Resources.Load <GameObject>(strPrefabeName); if (newSceneGameObject == null) { PPP.pppShow(); return(null); } GameObject go = GameObject.Instantiate(newSceneGameObject) as GameObject; if (go == null) { PPP.pppShow(); return(null); } SceneGame objSceneGame = go.GetComponent <SceneGame>(); UISceneBase objSceneUI = go.GetComponent <UISceneBase>(); if (objSceneGame == null && objSceneUI == null) { go.name = go.name.Replace("(Clone)", ""); var objTemp = PPPUIBase.addScript(go, go.name); if (objTemp != null) { objSceneGame = objTemp as SceneGame; if (objSceneGame == null) { objSceneUI = objTemp as UISceneBase; } } } if (objSceneGame != null) { #if UNITY_EDITOR UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Create Object"); #endif Transform t = go.transform; t.SetParent(Game.Instance.transform); go.layer = Game.Instance.gameObject.layer; if (objSceneGame.sceneUI == null) { var arrChild = objSceneGame.GetComponentsInChildren <UISceneBase>(); if (arrChild == null || arrChild.Length == 0) { PPP.pppShow(); return(null); } objSceneGame.sceneUI = arrChild[0]; objSceneGame.sceneUI.scene3D = objSceneGame; } objSceneGame.sceneUI.Page = page; LoadedScenes.Add(objSceneGame.sceneUI); // Allow the scene to initialize itself objSceneGame.sceneUI.InitializeScene(); if (hideScene == true) { objSceneGame.sceneUI.HideScene(); } return(objSceneGame.sceneUI); } else if (objSceneUI != null) { #if UNITY_EDITOR UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Create Object"); #endif Transform t = go.transform; t.SetParent(this.gameObject.transform); t.localPosition = Vector3.zero; t.localRotation = Quaternion.identity; t.localScale = Vector3.one; go.layer = this.gameObject.layer; objSceneUI.Page = page; LoadedScenes.Add(objSceneUI); // Allow the scene to initialize itself objSceneUI.InitializeScene(); if (hideScene == true) { objSceneUI.HideScene(); } return(objSceneUI); } else { PPP.pppShow(); } return(null); }
void OnApplicationQuit() { #if UNITY_EDITOR && UNITY_ANDROID bool isUpdate = false; { string strPath = Application.dataPath + "/Plugins/Android/common/AndroidManifest.xml"; if (File.Exists(strPath)) { string str = File.ReadAllText(strPath); var arrStr = str.Split('\"'); var strPackageDefine = "package="; var strWXEntryActivity = ".wxapi.WXEntryActivity"; var strWXPayEntryActivity = ".wxapi.WXPayEntryActivity"; var strFileProvider = ".fileProvider"; var strSchemeActivity = ".SchemeActivity"; var strXLEntryActivity = ".sgapi.SGEntryActivity"; var strXLSchemeID = "xianliao"; if (PPPGameConfig.strAndroidBundleID == null) { PPP.pppShow(); return; } for (int i = 0; i < arrStr.Length; i++) { if (arrStr[i] == null) { PPP.pppShow(); break; } if (arrStr[i].Contains(strPackageDefine)) { if (i + 1 < arrStr.Length) { var strPackage = arrStr[i + 1]; if (strPackage.Equals(PPPGameConfig.strAndroidBundleID) == false) { arrStr[i + 1] = PPPGameConfig.strAndroidBundleID; isUpdate = true; } } } else if (arrStr[i].Contains(strWXEntryActivity)) { string strTemp = PPPGameConfig.strAndroidBundleID + strWXEntryActivity; if (arrStr[i].Equals(strTemp) == false) { arrStr[i] = strTemp; isUpdate = true; } } else if (arrStr[i].Contains(strXLEntryActivity)) { string strTemp = PPPGameConfig.strAndroidBundleID + strXLEntryActivity; if (arrStr[i].Equals(strTemp) == false) { arrStr[i] = strTemp; isUpdate = true; } } else if (arrStr[i].Contains(strWXPayEntryActivity)) { string strTemp = PPPGameConfig.strAndroidBundleID + strWXPayEntryActivity; if (arrStr[i].Equals(strTemp) == false) { arrStr[i] = strTemp; isUpdate = true; } } else if (arrStr[i].Contains(strXLSchemeID)) { string strTemp = strXLSchemeID + PPPGameConfig.strXLAppKey; if (arrStr[i].Equals(strTemp) == false) { arrStr[i] = strTemp; isUpdate = true; } } else if (arrStr[i].Contains(strFileProvider)) { string strTemp = PPPGameConfig.strAndroidBundleID + strFileProvider; if (arrStr[i].Equals(strTemp) == false) { arrStr[i] = strTemp; isUpdate = true; } } else if (arrStr[i].Contains(strSchemeActivity)) { string strTemp = PPPGameConfig.strAndroidBundleID + strSchemeActivity; if (arrStr[i].Equals(strTemp) == false) { arrStr[i] = strTemp; isUpdate = true; } } } if (isUpdate) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < arrStr.Length; i++) { sb.AppendFormat("{0}\"", arrStr[i]); } sb.Remove(sb.Length - 1, 1); System.IO.File.WriteAllText(strPath, sb.ToString()); } } } if (isUpdate) { string strPath = Application.dataPath + "/Resources/GameConfig2.cs"; if (File.Exists(strPath)) { string str = File.ReadAllText(strPath); var arrStr = str.Split('\"'); var strVersionDefine = "strAndroidVersion="; bool isFind = false; for (int i = 0; i < arrStr.Length; i++) { if (arrStr[i].Contains(strVersionDefine)) { if (i + 1 < arrStr.Length) { var strVersion = arrStr[i + 1]; int version = 0; if (int.TryParse(strVersion, out version)) { version++; arrStr[i + 1] = version.ToString(); isFind = true; } } break; } } if (isFind) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < arrStr.Length; i++) { sb.AppendFormat("{0}\"", arrStr[i]); } sb.Remove(sb.Length - 1, 1); System.IO.File.WriteAllText(strPath, sb.ToString()); } } string strPathIcon = Application.streamingAssetsPath + "/" + PPP.strShareImagePath; string strPathDefault = Application.dataPath + "/Resources/icon.png"; File.Copy(strPathIcon, strPathDefault, true); } #endif }
void initProperty() { initDic(); var arrBtn = GetComponentsInChildren <Button>(true); if (arrBtn != null) { foreach (var item in arrBtn) { var btnTemp = item; item.onClick.AddListener(() => { this.OnClick(btnTemp); }); } } var type = this.GetType(); var arrField = type.GetFields(); foreach (var item in arrField) { var child = getChildByName(item.Name); //if (PPPGameConfig.PPP_DEBUG == 1 && PPPGameConfig.haveClientRule(PPPGameConfig.CLIENT_RULE.CHECK_NAME_DEFINE)) //{ checkName(child, item); //} if (child != null) { var typeItem = item.FieldType; if (item.FieldType == typeof(GameObject)) { item.SetValue(this, child.gameObject); } else if (item.FieldType == typeof(Transform)) { item.SetValue(this, child); } else if (isUIClass(typeItem)) { try { var value = child.GetComponent(typeItem); if (value != null) { item.SetValue(this, value); } else { if (isKindOfPPPUIBase(typeItem)) { var obj = addScript(child.gameObject, typeItem.FullName); if (obj != null) { item.SetValue(this, obj); } } } } catch (Exception) { PPP.pppShow(); continue; } } else if (typeItem.BaseType == typeof(Array)) { var strTypeOne = typeItem.FullName.Replace("[]", ""); var typeOne = PPP.GetType(strTypeOne); var list = getChildsByName(item.Name); if (list == null || typeOne == null) { continue; } if (isUIClass(typeOne)) { try { var arr = Array.CreateInstance(typeOne, list.Count); for (int i = 0; i < list.Count; i++) { var childTemp = list[i] as Transform; var value = childTemp.GetComponent(typeOne); if (value == null) { if (isKindOfPPPUIBase(typeOne)) { value = addScript(childTemp.gameObject, typeOne.FullName); } } arr.SetValue(value, i); if (value == null) { PPP.pppShow(); } } item.SetValue(this, arr); } catch (Exception) { PPP.pppShow(); continue; } } } else { continue; } } } var time2 = DateTime.Now; }