From 12db36c3c9a072f8383597a2cba73c908a1a0fba Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期四, 16 八月 2018 20:13:36 +0800
Subject: [PATCH] 更新lua 基础脚本框架

---
 Utility/ComponentExtersion.cs |   43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/Utility/ComponentExtersion.cs b/Utility/ComponentExtersion.cs
index 618ef80..5456b96 100644
--- a/Utility/ComponentExtersion.cs
+++ b/Utility/ComponentExtersion.cs
@@ -1,13 +1,36 @@
-锘縰sing System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
+锘縰sing UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.Events;
 using System;
-using TableConfig;
 
+[XLua.LuaCallCSharp]
 public static class ComponentExtersion
 {
+
+    public static Component FindChildComponent(this Component _component, string _type, string _path)
+    {
+        try
+        {
+            if (_component == null)
+            {
+                return null;
+            }
+
+            var transform = _component.transform.Find(_path);
+            if (transform == null)
+            {
+                return null;
+            }
+
+            return transform.GetComponent(_type);
+        }
+        catch (Exception ex)
+        {
+            DebugEx.Log(ex);
+            return null;
+        }
+
+    }
 
     public static T AddMissingComponent<T>(this Component _compoent) where T : Component
     {
@@ -57,6 +80,7 @@
         return component;
     }
 
+    [XLua.LuaCallCSharp]
     public static void AddListener(this Button _button, UnityAction _action)
     {
         if (_button == null)
@@ -66,6 +90,7 @@
         _button.onClick.AddListener(_action);
     }
 
+    [XLua.LuaCallCSharp]
     public static void RemoveAllListeners(this Button _button)
     {
         if (_button == null)
@@ -75,6 +100,7 @@
         _button.onClick.RemoveAllListeners();
     }
 
+    [XLua.LuaCallCSharp]
     public static void AddListener(this Toggle _toggle, UnityAction<bool> _action)
     {
         if (_toggle == null)
@@ -84,6 +110,7 @@
         _toggle.onValueChanged.AddListener(_action);
     }
 
+    [XLua.LuaCallCSharp]
     public static void RemoveAllListeners(this Toggle _toggle)
     {
         if (_toggle == null)
@@ -93,6 +120,7 @@
         _toggle.onValueChanged.RemoveAllListeners();
     }
 
+    [XLua.LuaCallCSharp]
     public static void AddListener(this Slider _slider, UnityAction<float> _action)
     {
         if (_slider == null)
@@ -102,6 +130,7 @@
         _slider.onValueChanged.AddListener(_action);
     }
 
+    [XLua.LuaCallCSharp]
     public static void RemoveAllListeners(this Slider _slider)
     {
         if (_slider == null)
@@ -111,6 +140,7 @@
         _slider.onValueChanged.RemoveAllListeners();
     }
 
+    [XLua.LuaCallCSharp]
     public static void AddListener(this InputField _inputField, UnityAction<string> _action)
     {
         if (_inputField == null)
@@ -120,6 +150,7 @@
         _inputField.onValueChanged.AddListener(_action);
     }
 
+    [XLua.LuaCallCSharp]
     public static void RemoveAllListeners(this InputField _inputField)
     {
         if (_inputField == null)
@@ -129,12 +160,14 @@
         _inputField.onValueChanged.RemoveAllListeners();
     }
 
+    [XLua.LuaCallCSharp]
     public static void SetEnable(this Button _btn, Text _btnTxt, bool _enable, EnableButtonConfig.EnableButtonType _type =
         EnableButtonConfig.EnableButtonType.Default)
     {
         EnableButtonConfig.SetEnable(_btn, _btnTxt, _enable, _type);
     }
 
+    [XLua.LuaCallCSharp]
     public static void SetInteractable(this Button _btn, Text _btnText, bool _interactable)
     {
         if (_btn != null)
@@ -153,6 +186,7 @@
         }
     }
 
+    [XLua.LuaCallCSharp]
     public static void SetSprite(this Image _image, string _id)
     {
         if (_image == null)
@@ -164,6 +198,7 @@
         _image.overrideSprite = sprite;
     }
 
+    [XLua.LuaCallCSharp]
     public static void SetSprite(this TextImage _textImage, string _id)
     {
         if (_textImage == null)

--
Gitblit v1.8.0