Exemplo n.º 1
0
 private void Start()
 {
     Instance = this;
     // hadSaveOnRunTime = false;
     Debug.Log("Start");
     isRunningGame = true;
 }
Exemplo n.º 2
0
        public static Transform LoadLayoutByPath(string select_path)
        {
            //Debug.Log("select_path : "+select_path);
            GameObject new_layout = CreatNewLayout(false);

            new_layout.transform.localPosition = new Vector3(new_layout.transform.localPosition.x, new_layout.transform.localPosition.y, 0);
            LayoutInfo layoutInfo = new_layout.GetComponent <LayoutInfo>();

            layoutInfo.LayoutPath = select_path;
            if (!File.Exists(select_path))
            {
                Debug.Log("UIEditorHelper:LoadLayoutByPath cannot find layout file:" + select_path);
                return(null);
            }
            string asset_relate_path = select_path;

            if (!select_path.StartsWith("Assets/"))
            {
                asset_relate_path = FileUtil.GetProjectRelativePath(select_path);
            }

            Object     prefab   = AssetDatabase.LoadAssetAtPath(asset_relate_path, typeof(Object));
            GameObject new_view = PrefabUtility.InstantiateAttachedAsset(prefab) as GameObject;

            new_view.transform.SetParent(new_layout.transform);
            new_view.transform.localPosition = Vector3.zero;
            new_view.transform.localScale    = Vector3.one;
            string just_name = System.IO.Path.GetFileNameWithoutExtension(asset_relate_path);

            new_view.name = just_name;
            new_layout.gameObject.name = just_name + "_Canvas";
            #if !UNITY_2018_3_OR_NEWER
            PrefabUtility.DisconnectPrefabInstance(new_view);    //链接中的话删里面的子节点时会报警告,所以还是一直失联的好,保存时直接覆盖prefab就行了
            #endif
            //打开界面时,从项目临时文件夹找到对应界面的参照图配置,然后生成参照图
            layoutInfo.ApplyConfig(asset_relate_path);
            ReopenLayoutOnExitGame.RecordOpenLayout(select_path, new_layout.transform.localPosition);
            return(new_layout.transform);
        }
Exemplo n.º 3
0
 private void OnDisable()
 {
     // Debug.Log("disable");
     Instance = null;
 }