from extplugins import ExtPlugin

class FKHeightAdjustUI(ExtPlugin):
    def __init__(self):
        if (ExtPlugin.exists("HS2_FKHeightAdjustUI")):
            ExtPlugin.__init__(self, "HS2_FKHeightAdjustUI")
        elif (ExtPlugin.exists("AI_FKHeightAdjustUI")):
            ExtPlugin.__init__(self, "AI_FKHeightAdjustUI")
        else:
            self.isDetected = False

    def GetPoseController(self, ociobj):
        from FKHeightAdjustUI import FKHeightAdjustUICharaController
        from Studio import OCIChar
        
        if isinstance(ociobj, OCIChar):
            return ociobj.charInfo.gameObject.GetComponent(FKHeightAdjustUICharaController)
        else:
            return None        

    def GetStateText(self, ocichar):
        from FKHeightAdjustUI import FKHeightAdjustUICharaController

        controller = self.GetPoseController(ocichar)
        if (controller):
            return float(controller.HeightAdjust)
        else:
            return None

    def SetStateText(self, ocichar, text):
        from FKHeightAdjustUI import FKHeightAdjustUICharaController
        controller = self.GetPoseController(ocichar)
        try:
            from System import Single
            controller.HeightAdjust = Single(text)
        except:
            pass