예제 #1
0
 def _load(self):
     for mod, scenes in config.ModList.iteritems():
         if not self._behaviorGos.ContainsKey(mod):
             console.log(Text.getText(Text.LOAD_MOD, mod.__name__))
             go = behavior_creator(mod.__name__, mod.MonoBehaviour, True)
             go.SetActive(False)
             self._behaviorGos.Add(mod, go)
         else:
             console.error(Text.getText(Text.MOD_ALREADY_EXIT, mod.__name__))
예제 #2
0
class Main(object):

    def __init__(self):
        self._behaviorGos = {}
        self._load()
        self.debug_go = None
        file_mgr.load(None) #load mod save


    def Update(self):
        #debug
        if Input.GetKeyDown(KeyCode.F12):
            if not self.debug_go:
                path2 = "C:/Users/Administrator/Desktop/New Unity Project 2/AssetBundles/StandaloneWindows/debug_hierarchy";
                asset2 = AssetBundle.LoadFromFile(path2);
                go = asset2.LoadAsset("Canvas");
                self.debug_go = GameObject.Instantiate(go);
                GameObject.DontDestroyOnLoad(self.debug_go);
                asset2.Unload(False);
            else:
                self.debug_go.SetActive(not self.debug_go.active);

        if Input.GetKeyDown(KeyCode.R) and Input.GetKey(KeyCode.LeftControl):
            self._reload()
        for mod in self._behaviorGos:
            if config.ModList[mod].Count <= 0 or config.ModList[mod].Contains(config.CurrentScene):
                self._behaviorGos[mod].SetActive(True);
            else:
                self._behaviorGos[mod].SetActive(False);
        for module, funs in updateCallback.iteritems():
            for fun in funs:
                fun()
       

    def _load(self):
        for mod, scenes in config.ModList.iteritems():
            if not self._behaviorGos.ContainsKey(mod):
                console.log(Text.getText(Text.LOAD_MOD, mod.__name__))
                go = behavior_creator(mod.__name__, mod.MonoBehaviour, True)
                go.SetActive(False)
                self._behaviorGos.Add(mod, go)
            else:
                console.error(Text.getText(Text.MOD_ALREADY_EXIT, mod.__name__))


    def _reload(self):
        try:
            for mod in self._behaviorGos.Keys:
                GameObject.DestroyImmediate(self._behaviorGos[mod])
                reload(mod)
                self._behaviorGos.Remove(mod)
                console.log(Text.getText(Text.UNLOAD_MOD, mod.__name__))
        except StandardError, e:
            print 'except:', e

        for module in config.CommandModules:
            console.log(Text.getText(Text.UNLOAD_CMD_SCRIPT, mod.__name__))
        updateCallback.Clear()
        self._load()
예제 #3
0
def error(msg):
    con = MonoBehaviour()
    if msg != "":
        msg = str(msg)
        print msg
        msg = Text.getText(Text.CONSOLE_ERROR, msg)
        con.longString += msg
        con.scrollTextPosition = Vector2(0, 9999)
예제 #4
0
def registerUpdateCallback(module, fun):
    if not updateCallback.ContainsKey(module):
        updateCallback.Add(module, [])
    for f in updateCallback[module]:
        if f.__name__ == fun.__name__:
            print(Text.getText(Text.EXIST_SAME_NAME_FUN, fun.__name__))
            return
    if not updateCallback[module].Contains(fun):
        updateCallback[module].Add(fun)
예제 #5
0
 def _reload(self):
     try:
         for mod in self._behaviorGos.Keys:
             GameObject.DestroyImmediate(self._behaviorGos[mod])
             reload(mod)
             self._behaviorGos.Remove(mod)
             console.log(Text.getText(Text.UNLOAD_MOD, mod.__name__))
     except StandardError, e:
         print 'except:', e
예제 #6
0
 def __init__(self):
     self.win_title = Text.getText(Text.CONSOLE_TITLE)
     self.tips = Text.getText(Text.CONSOLE_TIPS)
     self.options = Array.CreateInstance(GUILayoutOption, 0)
     self.gameObject = None  # will be assigned if exists as member
     self.component = None  # will be assigned if exists as member
     self.visible = False
     self.input = ""
     self.scrollTextPosition = Vector2()
     self.scrollCmdPosition = Vector2()
     self.longString = self.tips
     self.showCmdBtn = False
     self.commands = {}
     self.comHistory = []
     self.comHistoryIdx = 0
     self.win_width = max(Screen.width / 2, 500)
     self.win_height = Screen.height / 4
     self.consoleWinRect = Rect(0, 0, Screen.width / 2, Screen.height / 4)
     self.errorFlag = True