Exemplo n.º 1
0
    private static int NewChild(ILuaState lua)
    {
        GameObject parent, child;

        ApplyParentAndChild(lua, out parent, out child);
        if (child != null)
        {
            string     goName  = lua.OptString(3, child.name);
            GameObject go      = GoTools.AddChild(parent, child);
            int        sibling = lua.OptInteger(4, -1);
            if (parent)
            {
                if (sibling < 0)
                {
                    sibling = parent.transform.childCount + sibling;
                }
                go.transform.SetSiblingIndex(sibling);
            }
            if (go != null)
            {
                go.name = goName;
                lua.PushLightUserData(go);
            }
            else
            {
                lua.PushNil();
            }
        }
        else
        {
            lua.PushNil();
        }
        return(1);
    }
Exemplo n.º 2
0
    public static void InitEntry()
    {
#if UNITY_EDITOR
        var obj = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/" + ZFrame.Asset.AssetBundleLoader.DIR_ASSETS + "/AssetsMgr.prefab", typeof(GameObject));
        GoTools.AddChild(null, obj as GameObject);
        LogMgr.D("Game Launched from Level: {0}", SceneManager.GetActiveScene().name);
#endif
    }
Exemplo n.º 3
0
 /// <summary>
 /// 在此函数中加载UIRoot
 /// </summary>
 /// <param name="abRef"></param>
 /// <param name="md5"></param>
 /// <returns></returns>
 private Coroutine OnAssetsLaunched(AbstractAssetBundleRef abRef, string md5)
 {
     if (UIManager.Instance == null)
     {
         LoadAsync(typeof(GameObject), "Launch/UIROOT", false, (o, p) => {
             GoTools.AddForever(o as GameObject);
         });
     }
     return(null);
 }
Exemplo n.º 4
0
        static int Main(string[] args)
        {
            try
            {
                KApiLib.Construct();
                GoSdkLib.Construct();
                GoSystem   system = new GoSystem();
                GoSensor   sensor;
                KIpAddress ipAddress = KIpAddress.Parse(Constants.SENSOR_IP);
                sensor = system.FindSensorByIpAddress(ipAddress);
                sensor.Connect();
                system.EnableData(true);
                //retrieve setup handle
                GoSetup setup = sensor.Setup;
                //retrieve tools handle
                GoTools tools = sensor.Tools;
                // add ProfilePosition tool, retreive tool handle
                GoProfilePosition profilePositionTool = (GoProfilePosition)tools.AddTool(GoToolType.ProfilePosition);
                // set name for tool
                profilePositionTool.Name = "Profile position Test";
                // add Z measurement for ProfilePosition tool
                GoProfilePositionZ zProfileMeasurementTop = profilePositionTool.ZMeasurement;
                zProfileMeasurementTop.Enabled = true;
                zProfileMeasurementTop.Id      = 0;
                //set ProfilePosition feature to top
                GoProfileFeature profileFeature = profilePositionTool.Feature;
                profileFeature.FeatureType = GoProfileFeatureType.MaxZ;
                // set the ROI to fill the entire active area
                GoProfileRegion regionTop = profileFeature.Region;
                regionTop.X      = setup.GetTransformedDataRegionX(GoRole.Main);
                regionTop.Z      = setup.GetTransformedDataRegionZ(GoRole.Main);
                regionTop.Height = setup.GetTransformedDataRegionHeight(GoRole.Main);
                regionTop.Width  = setup.GetTransformedDataRegionWidth(GoRole.Main);
                // enable Ethernet output for measurement tool
                GoOutput   output         = sensor.Output;
                GoEthernet ethernetOutput = output.GetEthernet();
                ethernetOutput.ClearAllSources();
                ethernetOutput.AddSource(GoOutputSource.Measurement, 0);
            }
            catch (KException ex)
            {
                Console.WriteLine("Error: {0}", ex.Status);
            }
            // wait for ESC key
            Console.WriteLine("\nPress ENTER to continue");
            do
            {
                System.Threading.Thread.Sleep(100);
            } while (Console.Read() != (int)ConsoleKey.Enter);

            return(1);
        }
Exemplo n.º 5
0
    private static void chkWeaponPrefab(GameObject go)
    {
        var root = go.transform;

        var modelTrans = root.Find(MODEL_NAME);

        if (modelTrans == null)
        {
            string     path  = string.Format("Assets/Artwork/Model/Weapon/{0}.FBX", go.name);
            GameObject model = AssetDatabase.LoadAssetAtPath <GameObject>(path);
            if (model)
            {
                modelTrans      = GoTools.AddChild(go, model).transform;
                modelTrans.name = MODEL_NAME;
            }
            else
            {
                EditorUtility.DisplayDialog("提示",
                                            string.Format("未找到模型:\n{0}", path), "确定");
                return;
            }
        }
        modelTrans.localRotation = Quaternion.Euler(0, -90, -90);

        var rdr = modelTrans.GetComponentInChildren <SkinnedMeshRenderer>();

        if (rdr)
        {
            var mesh = rdr.gameObject.AddComponent <MeshFilter>();
            mesh.sharedMesh = rdr.sharedMesh;
            var meshRdr = rdr.gameObject.AddComponent <MeshRenderer>();
            meshRdr.sharedMaterials      = rdr.sharedMaterials;
            meshRdr.shadowCastingMode    = UnityEngine.Rendering.ShadowCastingMode.Off;
            meshRdr.receiveShadows       = false;
            meshRdr.useLightProbes       = false;
            meshRdr.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;
            SkinnedMeshRenderer.DestroyImmediate(rdr);
        }

        var muzzle = root.Find(MUZZLE_NAME);

        if (muzzle == null)
        {
            var goM = GoTools.AddChild(go, (GameObject)null);
            goM.name = MUZZLE_NAME;
            muzzle   = goM.transform;
            muzzle.SetParent(root);
        }
        muzzle.localRotation = Quaternion.Euler(0, -90, 0);

        go.SetLayerRecursively(LayerMask.NameToLayer("Role"));
    }
Exemplo n.º 6
0
    protected override void Awaking()
    {
        Application.logMessageReceived += logMessageReceived;
        logBuilder = new System.Text.StringBuilder(1024 * Kcapacity);
        counting   = 0;
        hasUpdate  = false;

        entText = grpText.GetChild(0).gameObject;
        GameObject newText = GoTools.AddChild(grpText.gameObject, entText);

        newText.name = "entText1";
        newText.SetActive(true);
        m_LogContent = newText.GetComponent <Text>();
        listText.Add(newText);
    }
Exemplo n.º 7
0
        public TcpClientHandler GetTcpHandler(string tcpName)
        {
            TcpClientHandler tcpHandler = null;
            var trans = cachedTransform.Find(tcpName);

            if (!trans)
            {
                var go = GoTools.AddChild(gameObject);
                go.name    = tcpName;
                tcpHandler = go.AddComponent <TcpClientHandler>();
            }
            else
            {
                tcpHandler = trans.GetComponent <TcpClientHandler>();
            }
            return(tcpHandler);
        }
Exemplo n.º 8
0
        public HttpHandler GetHttpHandler(string httpName)
        {
            HttpHandler httpHandler = null;
            var         trans       = cachedTransform.Find(httpName);

            if (!trans)
            {
                var go = GoTools.AddChild(gameObject);
                go.name                = httpName;
                httpHandler            = go.AddComponent <HttpHandler>();
                httpHandler.onHttpResp = OnHttpResponse;
                httpHandler.onHttpDL   = OnHttpDownload;
            }
            else
            {
                httpHandler = trans.GetComponent <HttpHandler>();
            }
            return(httpHandler);
        }
Exemplo n.º 9
0
        private void checkShowMain()
        {
            if (ui_MainUI)
            {
                ui_MainUI.SetActive(!ui_MainUI.IsActive());
            }
            else
            {
                //创建控件
                AssetsMgr.A.LoadAsync(typeof(GameObject), "get/TMainUI", false, (o, p) => {
                    if (ui_MainUI)
                    {
                        return;
                    }

                    GameObject root = GoTools.AddForever(o as GameObject);
                    ui_MainUI       = root.transform.FindChild("GETLevels").gameObject;
                    GETAssert.notNull(ui_MainUI, "没有找到预设:GETLevels");
                });
            }
        }
Exemplo n.º 10
0
    private void logMessageReceived(string condition, string stackTrace, LogType logType)
    {
        counting += 1;
        string toAppend = null;

        switch (logType)
        {
        case LogType.Log:
        case LogType.Warning:
            toAppend = string.Format(ColorFmt[(int)logType], counting, condition);
            break;

        case LogType.Assert:
        case LogType.Error:
        case LogType.Exception:
            toAppend = string.Format(ColorFmt[(int)logType], counting, condition, stackTrace);
            break;

        default:
            break;
        }
        var logLength = logBuilder.Length + toAppend.Length;

        if (logLength >= logBuilder.Capacity)
        {
            m_LogContent.text = m_LogContent.text.Remove(m_LogContent.text.Length - 1);
            logBuilder        = new System.Text.StringBuilder(Kcapacity * 1024);
            GameObject newText = GoTools.AddChild(grpText.gameObject, entText);
            newText.name = "entText" + (listText.Count + 1);
            newText.SetActive(true);
            m_LogContent = newText.GetComponent <Text>();
            listText.Add(newText);
        }
        logBuilder.AppendLine(toAppend);
        hasUpdate = true;
    }
Exemplo n.º 11
0
    // Use this for initialization
    private IEnumerator Start()
    {
        AssetsMgr.A.Loader.StopLoading();
        AssetsMgr.A.Loader.UnloadAll();
        sldLoading.gameObject.SetActive(false);
        yield return(null);

        if (!string.IsNullOrEmpty(loadingFx))
        {
            AssetsMgr.A.LoadAsync(typeof(GameObject), loadingFx, true, (uObj, o) => {
                var prefab = uObj as GameObject;
                if (prefab.GetComponent <RectTransform>())
                {
                    GoTools.AddChild(transform.parent.gameObject, prefab);
                }
                else
                {
                    GoTools.AddChild(null, prefab);
                }
            });
        }
        else
        {
            sldLoading.gameObject.SetActive(true);
            sldLoading.value = 0f;
        }

        strTrace  = new System.Text.StringBuilder();
        beginTime = Time.realtimeSinceStartup;
        lastTime  = beginTime;

        // 执行预加载
        nAssetBundleLoaded = 0;
        nAssetBundleToLoad = AssetsMgr.A.Loader.ExecutePreload(OnAssetBundlesLoading, OnAssetBundlesLoaded);

        float progress = 0;

        while (nAssetBundleLoaded < nAssetBundleToLoad)
        {
            float add = assetsRate - progress;
            progress        += Mathf.Min(add, barStep);
            sldLoading.value = progress * assetsProg;
            yield return(null);
        }
        assetsProg = sldLoading.value;

        var asynOpt = AssetsMgr.A.Loader.LoadLevelAsync(levelToLoad);

        progress = 0;
        while (!asynOpt.isDone)
        {
            float add = asynOpt.progress - progress;
            progress        += Mathf.Min(add, barStep);
            sldLoading.value = progress * (1 - assetsProg) + assetsProg;
            yield return(null);
        }

        while (sldLoading.value < 1)
        {
            sldLoading.value += barStep;
            yield return(null);
        }

        yield return(new WaitForSeconds(2));

        finishLoading();
        //StartCoroutine("FinishLoading");
        ObjectPoolManager.DestroyPooled(gameObject);
    }