Ejemplo n.º 1
0
 protected StepMenuControl(UnsMachineLogic logic, string name, ModelType type)
 {
     this.name = name;
     this.type = type;
     this.cc   = new CC {
         logic = logic
     };
 }
Ejemplo n.º 2
0
    private bool InitLogic()
    {
        GUIStyle txtStyle = new GUIStyle(EditorWindowStyle.h3FontStyle);

        txtStyle.alignment        = TextAnchor.MiddleCenter;
        txtStyle.normal.textColor = Color.red;
        GUILayout.BeginVertical(EditorWindowStyle.backBlackBoderGray, GUILayout.Width(500));

        if (logic == null)
        {
            obj_MachineStep = EditorGUILayout.ObjectField("打开文件", obj_MachineStep, typeof(TextAsset), true) as TextAsset;
            UnsMachineLogic json = null;

            try
            {
                json = JsonUtility.FromJson <UnsMachineLogic>(obj_MachineStep.text);

                if (json == null)
                {
                    bl_HasAsset = false;
                    GUILayout.Label("文件錯誤", txtStyle);
                }
                else
                {
                    bl_HasAsset = true;
                }
            }
            catch (System.Exception e)
            {
                Debug.Log(e);
                bl_HasAsset = false;
                GUILayout.Label("文件錯誤", txtStyle);
            }


            GUILayout.BeginHorizontal();
            if (bl_HasAsset)
            {
                if (GUILayout.Button("打开"))
                {
                    logic      = json;
                    bl_CanInit = true;
                }
            }
            if (GUILayout.Button("新建"))
            {
                logic      = new UnsMachineLogic();
                bl_CanInit = true;
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.EndVertical();
        return(bl_CanInit);
    }
Ejemplo n.º 3
0
    public static void Save(UnsMachineLogic logic)
    {
        string json = RemoveOther(JsonUtility.ToJson(logic));

        FileStream   fs = new FileStream(assetPath + DateTime.Now.ToString("yyyyMMdhhmmss") + ".json", FileMode.CreateNew);
        StreamWriter sw = new StreamWriter(fs);

        sw.WriteLine(json);
        sw.Dispose();
        fs.Dispose();

        AssetDatabase.Refresh();
    }
Ejemplo n.º 4
0
    void OnGUI()
    {
        ReStart();

        if (!InitLogic())
        {
            return;
        }

        InitMenu();

        if (menuControl == null)
        {
            menuControl = new MenuWindowControl();
            menuControl.GetWindow(this);
        }

        GUILayout.BeginHorizontal();
        menuControl.OnGUI();

        if (menuControl.bl_Clicked)
        {
            if (menus[menuControl.menuSelected].type != currentType)
            {
                BoundModel(menus[menuControl.menuSelected].type);
                currentType = menus[menuControl.menuSelected].type;
            }

            menus[menuControl.menuSelected].GetWindow();

            menuControl.bl_Clicked = false;
        }

        menus[menuControl.menuSelected].OnGUI();
        GUILayout.EndHorizontal();

        Rect rectBtn = new Rect(this.position.width - 200, 0, 200, 30);

        if (GUI.Button(rectBtn, "保存"))
        {
            UnsMachineLogic.Save(logic);
        }
    }
Ejemplo n.º 5
0
 public InfomationWindowControl(UnsMachineLogic logic, string name, ModelType type) : base(logic, name, type)
 {
     info             = logic.Infomation;
     str_PropertyName = "Infomation";
 }
 public ProcessWindowControl(UnsMachineLogic logic, string name, ModelType type) : base(logic, name, type)
 {
     info             = cc.logic.Process;
     str_PropertyName = "Process";
 }
Ejemplo n.º 7
0
 public MatchWindowControl(UnsMachineLogic logic, string name, ModelType type) : base(logic, name, type)
 {
     info             = logic.Match;
     str_PropertyName = "Match";
 }