public TestPop4() { m_popId = POP_ID.TEST_POP_4; m_layerIdx = POP_LAYER_IDX.LAYER_POP_1; ShowGameObject(); // m_btnOk = GetChildByName <KButton>("Button_Ok", true); m_btnClose = GetChildByName <KButton>("Button_Close", true); m_panel = GameObjUtil.GetParent(m_btnOk.gameObject); // m_inputName = GetChildByName <KInputField>("Input_name", true); m_labelTestInput = GetChildByName <KText>("Label_testInput", true); // m_tgl_1 = GetChildByName <KToggle>("Toggle_position1", true); m_labelTgl_1 = GetChildByName <KText>(m_tgl_1.gameObject, "Label_Text", true); m_tglGroup_1 = GetChildByName <KToggleGroup>("ToggleGroup_a1", true); // m_sliderSchedule = GetChildByName <KSlider>("Slider_Schedule1", true); m_labelSchedule = GetChildByName <KText>("Label_testSilder", true); // m_barLoading = GetChildByName <KProgressBar>("ProgressBar_loading", true); // m_icon = GetChildByName <KImage>("Image_sharedAnchor", true); // m_scrollView = GetChildByName <KScrollView>("ScrollView_GuildList", true); m_listView = ComponentUtil.EnsureComponent <KListViewScroll>(m_scrollView.gameObject); }
//-------∽-★-∽------∽-★-∽--------∽-★-∽ApplyGameObjectParam∽-★-∽--------∽-★-∽------∽-★-∽--------// public override void ApplyGameObjectParam(GameObject go, JsonData data) { base.ApplyGameObjectParam(go, data); KSlider slider = go.AddComponent <KSlider>(); ComponentUtil.AddChildComponent <StateImage>(go, "Container_fillArea/Container_fillHolder/Image_fill"); //slider.AddChildComponent<StateImage>("Container_fillArea/Container_fillHolder/Image_fill"); if (HasParam(data, PATTERN_DIRECTION) == true) { string param = GetParam(data, PATTERN_DIRECTION); if (param == PARAM_RIGHT2LEFT) { slider.direction = Slider.Direction.RightToLeft; } else if (param == PARAM_TOP2BOTTOM) { slider.direction = Slider.Direction.TopToBottom; } else if (param == PARAM_BOTTOM2TOP) { slider.direction = Slider.Direction.BottomToTop; } } }
protected void AddItemAt(Type itemType, object data, int index, bool doLayoutImmediately = true) { if (m_isExecutingCoroutine == true) { Log.Error("有尚未执行完毕的协程~~", this); return; } //要改成循环利用 GameObject go = GameObjUtil.Instantiate(m_itemTemplate); go.transform.SetParent(this.transform); go.transform.localScale = Vector3.one; go.transform.localPosition = Vector3.zero; go.SetActive(true); //BuildItem(go); KListItem item = ComponentUtil.EnsureComponent(go, itemType) as KListItem; item.Index = index; item.name = GenerateItemName(index); AddItemEventListener(item); m_itemList.Insert(index, item); item.SetData(data); //设置数据 if (doLayoutImmediately) { RefreshAllItemLayout(); } }
//-------∽-★-∽------∽-★-∽--------∽-★-∽ListViewScroll∽-★-∽--------∽-★-∽------∽-★-∽--------// void ShowListViewScroll() { m_listViewScroll = ComponentUtil.EnsureComponent <KListViewScroll>(m_scrollViewItemList.gameObject); m_listViewScroll.itemViewType = typeof(Item1); m_listViewScroll.onDataChanged.AddListener(UpdateListItem2); LayoutParam param = m_listViewScroll.layoutParam; //param.padding = new Padding(20, 20, 20, 20); param.itemGap = new Vector2(10, 50); param.divNum = 3; //param.dir = LayoutDirection.LeftToRight; List <int> datas = new List <int>(); int num = 999; for (int i = 0; i < num; ++i) { datas.Add(i); } //m_listViewScroll.direction = KScrollView.ScrollDir.horizontal; m_listViewScroll.ShowList(datas); }
protected override void __Initialize() { m_scrollable = true; m_maskTrans = GetChildComponent <RectTransform>("Image_mask"); //遮罩 GameObject contentGo = GameObjUtil.FuzzySearchChild(m_maskTrans.gameObject, "content"); m_contentTrans = contentGo.GetComponent <RectTransform>(); m_contentTrans.anchoredPosition = Vector2.zero; m_contentTrans.sizeDelta = new Vector2(m_maskTrans.rect.width, m_maskTrans.rect.height); m_scrollRect = ComponentUtil.EnsureComponent <ScrollRect>(this.gameObject); RefreshScrollRectSetting(); m_scrollRect.viewport = m_maskTrans; m_scrollRect.content = m_contentTrans; if (GetChild("Container_arrow") != null) { //有箭头 m_scrollArrow = AddChildComponent <KScrollViewArrow>("Container_arrow"); } m_scrollRect.onValueChanged.AddListener(OnInternalValueChanged); }
private void OnTriggerEnter(Collider other) { if (!other.CompareTag("Player") && !other.CompareTag("Enemy")) { return; } if (other.gameObject.GetComponent <PowerUp>() == null) { ComponentUtil.CopyComponent(action, other.gameObject); if (logo != null) { other.GetComponent <PowerUp>().logo = logo; } //UnityEditorInternal.ComponentUtility.CopyComponent(action); //UnityEditorInternal.ComponentUtility.PasteComponentAsNew(other.gameObject); } GameObject.FindObjectOfType <Mendel>().updateValue(Int32.Parse(other.name), 30); /* * var info = other.gameObject.GetComponent<PlayerHealth>(); * info.ModifyStats(healthRestoration,shield,bomb,shoe); */ Destroy(gameObject); }
static int GetComponentInChildren(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && TypeChecker.CheckTypes <System.Type>(L, 2)) { UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); System.Type arg1 = (System.Type)ToLua.ToObject(L, 2); UnityEngine.Component o = ComponentUtil.GetComponentInChildren(arg0, arg1); ToLua.Push(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes <string>(L, 2)) { UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); string arg1 = ToLua.ToString(L, 2); UnityEngine.Component o = ComponentUtil.GetComponentInChildren(arg0, arg1); ToLua.Push(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: ComponentUtil.GetComponentInChildren")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetLuaComponentsInChildren(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1) { UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); LuaComponent[] o = ComponentUtil.GetLuaComponentsInChildren(arg0); ToLua.Push(L, o); return(1); } else if (count == 2) { UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); string arg1 = ToLua.CheckString(L, 2); System.Collections.Generic.List <LuaComponent> o = ComponentUtil.GetLuaComponentsInChildren(arg0, arg1); ToLua.PushSealed(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: ComponentUtil.GetLuaComponentsInChildren")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int InstantiateGlobal(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1) { UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); UnityEngine.GameObject o = ComponentUtil.InstantiateGlobal(arg0); ToLua.PushSealed(L, o); return(1); } else if (count == 2) { UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); UnityEngine.GameObject arg1 = (UnityEngine.GameObject)ToLua.CheckObject(L, 2, typeof(UnityEngine.GameObject)); UnityEngine.GameObject o = ComponentUtil.InstantiateGlobal(arg0, arg1); ToLua.PushSealed(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: ComponentUtil.InstantiateGlobal")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static void Revert() { print("Start replacing any AnubisInputFieldTMP to TMP_InputFields"); int i = 0; foreach (var aif_InputField in FindAllObjectsOfTypeExpensive <AnubisInputField>().ToList()) { var inputFieldGo = aif_InputField.gameObject; var tempInputField = new GameObject().AddComponent <AnubisInputField>(); EditorUtility.CopySerialized(aif_InputField, tempInputField); DestroyImmediate(aif_InputField); ComponentUtil.CopyPastSerialized(tempInputField, inputFieldGo.AddComponent <TMP_InputField>()); DestroyImmediate(tempInputField.gameObject); print("Replaced: " + inputFieldGo.name); i++; } print("Successfully Replaced " + i + " Anubis Input Fields"); }
//-------∽-★-∽------∽-★-∽--------∽-★-∽ListView∽-★-∽--------∽-★-∽------∽-★-∽--------// void ShowListView() { GameObject container = GameObjUtil.FindChild(m_scrollViewItemList.gameObject, "Image_mask/Container_content"); List <int> datas = new List <int>(); int num = 10; for (int i = 0; i < num; ++i) { datas.Add(i); } m_listView = ComponentUtil.EnsureComponent <KListView>(container); m_listView.itemViewType = typeof(Item1); m_listView.onDataChanged.AddListener(UpdateListItem); LayoutParam param = m_listView.layoutParam; //param.padding = new Padding(20, 20, 20, 20); param.itemGap = new Vector2(10, 50); //param.divNum = 2; m_listView.ShowList(datas); }
public IEnumerable <T> GetTargets <T>(object triggerArg) where T : class { foreach (var obj in this.ReduceTargets(triggerArg)) { if (obj == null) { continue; } var result = ObjUtil.GetAsFromSource <T>(obj); if (result == null && !_configured && obj == triggerArg && ComponentUtil.IsAcceptableComponentType(typeof(T))) { //if not configured, and the triggerArg didn't reduce properly, lets search the entity of the 'triggerArg' var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); if (go == null) { continue; } result = go.FindComponent <T>(); } if (result != null) { yield return(result); } } }
public static object GetFromTarget(GameObject targ, System.Type restrictionType, EntityRelativity relativity) { switch (relativity) { case EntityRelativity.Entity: { targ = targ.FindRoot(); var obj = ObjUtil.GetAsFromSource(restrictionType, targ); if (object.ReferenceEquals(obj, null) && ComponentUtil.IsAcceptableComponentType(restrictionType)) { obj = targ.GetComponentInChildren(restrictionType); } return(obj); } case EntityRelativity.Self: { return(ObjUtil.GetAsFromSource(restrictionType, targ)); } case EntityRelativity.SelfAndChildren: { var obj = ObjUtil.GetAsFromSource(restrictionType, targ); if (object.ReferenceEquals(targ, null) && ComponentUtil.IsAcceptableComponentType(restrictionType)) { obj = targ.GetComponentInChildren(restrictionType); } return(obj); } default: return(null); } }
static int QPYX_InstantiateGlobal_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 1) { UnityEngine.GameObject QPYX_arg0_YXQP = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.GameObject)); UnityEngine.GameObject QPYX_o_YXQP = ComponentUtil.InstantiateGlobal(QPYX_arg0_YXQP); ToLua.PushSealed(L_YXQP, QPYX_o_YXQP); return(1); } else if (QPYX_count_YXQP == 2) { UnityEngine.GameObject QPYX_arg0_YXQP = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.GameObject)); UnityEngine.GameObject QPYX_arg1_YXQP = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 2, typeof(UnityEngine.GameObject)); UnityEngine.GameObject QPYX_o_YXQP = ComponentUtil.InstantiateGlobal(QPYX_arg0_YXQP, QPYX_arg1_YXQP); ToLua.PushSealed(L_YXQP, QPYX_o_YXQP); return(1); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: ComponentUtil.InstantiateGlobal")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
internal void SetGameObject(GameObject gameObject, object data = null) { this.gameObject = gameObject; var isActive = this.gameObject.activeInHierarchy; AutoReference(); _z = ComponentUtil.AutoGet <ZeroView>(this.gameObject); _z.aViewClass = GetType().FullName; _z.onEnable += OnGameObjectEnable; _z.onDisable += OnGameObjectDisable; _z.onDestroy += OnGameObjectDestroy; OnInit(data); /* * 通过isActive来限定,只有当gameObject本来为activeInHierarchy状态, * 并且执行OnInit后还在activeInHierarchy状态时,才调用OnEnable,因为 * OnInit中可能执行了SetActive,并且触发了OnGameObjectEnable或OnGameObjectDisable */ if (isActive && this.gameObject.activeInHierarchy) { OnEnable(); } }
public System.Collections.IEnumerable GetTargets(System.Type tp, object triggerArg) { foreach (var obj in this.ReduceTargets(triggerArg)) { if (obj == null) { continue; } var result = ObjUtil.GetAsFromSource(tp, obj); if (result == null && !_configured && obj == triggerArg && ComponentUtil.IsAcceptableComponentType(tp)) { //if not configured, and the triggerArg didn't reduce properly, lets search the entity of the 'triggerArg' var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); if (go == null) { continue; } result = go.FindComponent(tp); } if (result != null) { yield return(result); } } }
static int QPYX_GetComponentInChildren_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 2 && TypeChecker.CheckTypes <System.Type>(L_YXQP, 2)) { UnityEngine.GameObject QPYX_arg0_YXQP = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.GameObject)); System.Type QPYX_arg1_YXQP = (System.Type)ToLua.ToObject(L_YXQP, 2); UnityEngine.Component QPYX_o_YXQP = ComponentUtil.GetComponentInChildren(QPYX_arg0_YXQP, QPYX_arg1_YXQP); ToLua.Push(L_YXQP, QPYX_o_YXQP); return(1); } else if (QPYX_count_YXQP == 2 && TypeChecker.CheckTypes <string>(L_YXQP, 2)) { UnityEngine.GameObject QPYX_arg0_YXQP = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.GameObject)); string QPYX_arg1_YXQP = ToLua.ToString(L_YXQP, 2); UnityEngine.Component QPYX_o_YXQP = ComponentUtil.GetComponentInChildren(QPYX_arg0_YXQP, QPYX_arg1_YXQP); ToLua.Push(L_YXQP, QPYX_o_YXQP); return(1); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: ComponentUtil.GetComponentInChildren")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
public object GetTarget(System.Type tp, object triggerArg) { if (tp == null) { throw new System.ArgumentNullException("tp"); } var obj = this.ReduceTarget(triggerArg); if (obj == null) { return(null); } var result = ObjUtil.GetAsFromSource(tp, obj); if (result == null && this.ImplicityReducesEntireEntity && ComponentUtil.IsAcceptableComponentType(tp)) { //if not configured, and the triggerArg didn't reduce properly, lets search the entity of the 'triggerArg' var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); if (go == null) { return(null); } result = go.FindComponent(tp); } return(result); }
public static void Convert() { print("Start replacing any TMP_InputField to AnubisInputFieldTMP"); int i = 0; //For each TMP_Input field in the loaded scene foreach (var tmp_InputField in FindAllObjectsOfTypeExpensive <TMPro.TMP_InputField>().ToList()) { var inputFieldGo = tmp_InputField.gameObject; //Creating a tmp gameobj to hold the same serialized properties of current TMP_InputField script, //as we cannot AddComponent of an AnubisInputField script while TMP_InputField script still attached to gameobj var tmpGoTMP_InputField = new GameObject().AddComponent <TMP_InputField>(); //Copy and paste serialized properties of current TMP_InputField script to temp gameobj TMP_InputField script EditorUtility.CopySerialized(tmp_InputField, tmpGoTMP_InputField); //Remove TMP_InputField script, to replace with AnubisInputField DestroyImmediate(tmp_InputField); //Create AnubisInputField and paste TMP_InputField serialized properties ComponentUtil.CopyPastSerialized(tmpGoTMP_InputField, inputFieldGo.AddComponent <AnubisInputField>()); //Remove tempGo as its not needed anymore DestroyImmediate(tmpGoTMP_InputField.gameObject); print("Replaced: " + inputFieldGo.name); i++; } print("Successfully Replaced " + i + " TMP Input Fields"); }
/// <summary> /// Finds all types in the application context which are known components /// </summary> /// <param name="assemblyFilters">Regexes which allow an assembly if matched.</param> /// <returns></returns> private IEnumerable <Type> ScanComponents(params string[] assemblyFilters) { var componentScanner = ComponentUtil.BuildComponentScanner(); Log.Info("Scanning for [Component] / [Service] / etc. classes..."); return(componentScanner.ScanByAttribute(assemblyFilters).ToList()); }
/// <summary> /// 构建组件内置的 class 样式。 /// </summary> /// <param name="collection"></param> protected override void CreateComponentCssClass(ICollection <string> collection) { collection.Add("form-control"); if (Size != Size.Default) { collection.Add(ComponentUtil.GetSizeCssClass(Size, "form-control-")); } }
//初始化人物位置 public void Awake() { m_cameraTP = ComponentUtil.EnsureComponent <CameraTPerson>(m_camera.gameObject); m_cameraTP.SetTarget(transform); m_cameraTP.SetDefault(30, 30); ComponentUtil.EnsureComponent <CameraTPMouse>(m_camera.gameObject); }
public void TestAutoConfiguration() { var componentScanner = ComponentUtil.BuildComponentScanner(); var components = componentScanner.ScanByAttribute("Archimedes.*").ToList(); var conf = new ComponentRegisterer(new ElderModuleConfiguration()); conf.RegisterComponents(components); }
public void TestComponentScan() { var componentScanner = ComponentUtil.BuildComponentScanner(); var components = componentScanner.ScanByAttribute("Archimedes.*").ToList(); Assert.True(components.Contains(typeof(ServiceA)), ""); Assert.True(components.Contains(typeof(ServiceB)), ""); Assert.True(components.Contains(typeof(ServiceC)), ""); Assert.True(components.Contains(typeof(ServiceD)), ""); }
public bool Update() { switch (state) { case 0: if (currentAction.Update()) { currentAction.End(); state = 1; currentAction = new PickDropAction(player); } return(false); case 1: if (currentAction.Update()) { currentAction.End(); state = 2; ClientPlateStation deliverStation = ComponentUtil .GetClosestComponent <ClientPlateStation>(player.transform.position); Logger.Log($"Current pos: {Logger.FormatPosition(player.transform.position)}, " + $"station pos: {Logger.FormatPosition(deliverStation.transform.position)}"); currentAction = new PathFindAction(player, deliverStation); } return(false); case 2: if (currentAction.Update()) { currentAction.End(); state = 3; currentAction = new PickDropAction(player); } return(false); case 3: if (currentAction.Update()) { currentAction.End(); return(true); } return(false); default: return(false); } }
void IStateModifier.ModifyWith(object targ, StateToken token) { var cam = ComponentUtil.GetComponentFromSource <Camera>(targ); if (cam == null) { return; } token.CopyTo(cam); }
void IStateModifier.ModifyWith(object targ, object source) { var cam = ComponentUtil.GetComponentFromSource <Camera>(targ); if (cam == null) { return; } DynamicUtil.CopyState(cam, source); }
void IStateModifier.Modify(object targ) { var cam = ComponentUtil.GetComponentFromSource <Camera>(targ); if (cam == null) { return; } _cameraSettings.CopyTo(cam); }
protected override void OnInit(object data) { base.OnInit(data); var blurT = transform.Find("Blur"); if (null != blurT) { _blur = ComponentUtil.AutoGet <Blur>(blurT.gameObject); _blur.gameObject.SetActive(false); } }
public static void GetComponentsOnTarg(GameObject container, ICollection <T> coll, bool includeComponentsOnContainer) { if (includeComponentsOnContainer) { ComponentUtil.GetComponentsAlt <T>(container, coll); } for (int i = 0; i < container.transform.childCount; i++) { ComponentUtil.GetComponentsAlt <T>(container.transform.GetChild(i), coll); } }